HI!
I have a next.js app that integrates builder.io and BigCommerce to manage the frontend of an ecommerce.
In my integration I am trying to use builder.io (as well as a CMS) to define the layout of the product page to which the data retrieved from the BigCommerce API will then be dynamically passed.
export function RenderBuilerSection({ content, model }: BuilderPageProps) {
const isPreviewing = useIsPreviewing();
if (content || isPreviewing) {
//Product data comes from bigCommerce API
return <BuilderComponent data={productData} content={content} model={model} options={{cache: true, cachebust: true}}/>;
}
return <ErrorRender model={model} />
}
These pages must be generated server side to be SEO friendly and to improve performance.
Now, the problem is that with the “AppRouter” approach it is not possible for me to use the “BuilderComponent” component in a server component. I would like to understand if I’m doing something wrong or if this is actually a limit of my stack and if I have to use Next’s “Pages” approach
I’ve already read this page and it’s a not totally clear for me, 'couse it say to use getStaticProps combined with getAsyncProps but, with new approach “AppRouter” the getStaticProps was abandoned and now it is automatically inside the fetch function as you can read here.
And if i try to use BuilderComponent in a non ‘use client’ component i got this error
It appears that our GEN1 React SDK doesn’t support server-side components. As an alternative, we suggest using our Builder NextJS SDK, @builder.io/sdk-react-nextjs. This SDK is specifically designed for use with NextJS’s app directory and includes essential dependencies tailored to NextJS-specific functionality.
Hi @manish-sharma,
We’re facing some similar situation. I’d like to upgrade my project to the GEN2 nextjs sdk to leverage the benefits of server-side components.
Would you please show how to properly register a component which accepts children? Which would be the replacement in GEN2 for the following code?