Please fill out as many of the following questions as possible so we can help you promptly! If you don’t know how to answer or it does not apply, feel free to remove it or leave it blank.
Builder content link
Builder public api key
Using the Builder API Key - Builder.io
NEXT_PUBLIC_BUILDER_API_KEY=3c5869701f8c4c11945f89d9bd9ec4ac
What are you trying to accomplish
I am trying to view the live preview of my homepage
Screenshots or video link
Code stack you are integrating Builder with
next js
Reproducible code example
import { builder } from "@builder.io/sdk";
import { RenderBuilderContent } from "../../components/builder";
// Builder Public API Key set in .env file
builder.init(process.env.NEXT_PUBLIC_BUILDER_API_KEY!);
interface PageProps {
params: {
page: string[];
};
}
export default async function Page(props: PageProps) {
const builderModelName = "page";
const content = await builder
// Get the page content from Builder with the specified options
.get(builderModelName, {
userAttributes: {
// Use the page path specified in the URL to fetch the content
urlPath: "/" + (props?.params?.page?.join("/") || ""),
},
})
// Convert the result to a promise
.toPromise();
return (
<>
{/* Render the Builder page */}
<RenderBuilderContent content={content} model={builderModelName} />
</>
);
}