What are you trying to accomplish
Does the builder.io integration with NextJS support client-side routing out of the box with the ready components?
If I want to make a SPA does that mean I have to create all the links in it as custom components and I can’t use the out-of-the-box components?
I am new to builder.io, I am sorry if this is covered somewhere or if I am missing something and it is a dumb question.
Code stack you are integrating Builder with
NextJS
Builder.io’s integration with Next.js does support client-side routing, allowing you to create a Single Page Application (SPA) that leverages Builder.io’s components. However, you might need to handle client-side navigation with custom components or tweak the default behavior to ensure smooth client-side transitions.
Client-Side Routing in Next.js
Next.js provides built-in support for client-side routing with the <Link> component from next/link. To use this with Builder.io content, you can integrate the custom link component into your Builder components.
Using Custom Components for Client-Side Navigation
Builder.io allows you to define custom components, which you can use to set up client-side navigation using Next.js’ <Link> component. This approach ensures you have control over how links behave in your SPA.
Step-by-Step Guide:
Set Up Next.js with Builder.io:
If you haven’t already, initialize your Next.js app and integrate Builder by following the integration guide.
Create a Custom Link Component:
Create a custom link component that uses Next.js’ <Link> component for client-side navigation.
In the Builder.io Visual Editor, you can now use the CustomLink component to create links.
Drag the CustomLink component into your pages or sections and set the URL and text properties.
Ensuring Client-Side Routing:
Ensure your Next.js page and API routes are correctly configured.
Ensure that your app shell (layout) remains consistent and does not completely reload on client-side navigation. This can be configured in your _app.js or _app.tsx.
With Builder.io’s integration with Next.js, client-side routing in a SPA is supported, but it may require custom components for client-side navigation. By creating and registering custom link components, you can fully leverage Next.js’s client-side routing capabilities while using Builder.io to manage and create content dynamically.