Integrate Visual Editing of Your Homepage
Enterprise plans
A direct option for giving non-developer teammates access to editing your homepage is to integrate landing pages and use the same code for your homepage. In this way, choosing / as a page's URL shows it on the homepage.
Alternatively, you can make a dedicated section model for your homepage. This is preferable if you make many variations of your homepage.
Model definition
A standard section model named homepage is all you need.
By default, you don't need any fields but may choose to add targeting to show different visitors different versions of your homepage.
Example code
Notice that RenderBuilderContent is a component you'd make, for example:
Install the SDK:
Next, create a new React component that fetches the Builder.io content and renders it using the BuilderComponent.
Place this code in any file you want to represent the homepage of your React app. Typically, you might put this code in a file named HomePage.js or HomePage.jsx.
Make sure to replace YOUR_PUBLIC_API_KEY with your own Builder.io Public API key.
Install the SDK:
Place the following code in a file inside the src directory with a filename that matches the route that you want to render the Builder content on.
For example, if you wanted to render Builder content on the /collections/:collection route, you would create a file at src/collections/[collection].tsx and place the code in that file.
Make sure to replace YOUR_PUBLIC_API_KEY with your own Builder.io Public API key.
This example uses SvelteKit.
Install the SDK:
Define a load() function in Home.js. Home.js is where the Builder content is fetched and returned as props.
In home.svelte, render the Builder content using the Content component.
Make sure to replace YOUR_PUBLIC_API_KEY with your own Builder.io Public API key.
Install the SDK:
Fetch the content with the onMounted lifecycle hook and render it using the Content component from Builder.io's Vue SDK; for example:
Make sure to replace YOUR_API_KEY with your own Builder.io Public API key.
Install the SDK:
Next, use asyncData() method to fetch the homepage content from Builder.io before initializing the component. This way, the fetched content will be available when the component is rendered.
The Content component then renders the Builder.io content for the homepage model when the homepage data is available.
Add the following to nuxt.config.js:
If you are using an SSR framework other than Nuxt, you must import the CSS by adding the following to your entry point, before rendering Builder content:
Make sure to replace YOUR_API_KEY with your own Builder.io Public API key.
Install the SDK:
Create a new Qwik component that fetches and renders the Builder.io content using the Builder.io SDK for Qwik:
Make sure to replace YOUR_PUBLIC_API_KEY with your own Builder.io Public API key.
Import the BuilderPage component and use it in your main Qwik component; for example index.tsx:
Fetch the data with a resolver:
In homepage.component.ts, subscribe to the route's resolved data from the resolver, in order to render it in the template.
Install the SDK:
Fetch the homepage content from Builder.io using Gatsby's createPages API in gatsby-node.js.
Then pass the fetched content as a prop to the HomePage component through the pageContext object. The BuilderComponent renders the Builder.io content for the homepage model.
First, create a new file src/templates/homepage.js with the following content:
Then, modify your gatsby-node.js file to fetch the homepage content from Builder.io and create a page using the homepage.js template:
Make sure to replace YOUR_API_KEY with your own Builder.io Public API key.
Import Builder and fetch the homepage, making sure to replace YOUR_PUBLIC_API_KEY with your Builder Public API Key.
Install the SDK:
Create a new component; for example., homepage.component.ts:
Paste the following in the corresponding template file, homepage.component.html:
Import the BuilderModule in your app.module.ts:
Add the new component's route to your app-routing.module.ts: