Home App Docs Blog Github

Select template depending on loaded data

We’d like to create a product page, using Builder. Basically, the URL for all products suppose to be like /product/:id

Building components are clear, and adding them to Builder is also clear, as well as creating pages out of components.

The next thing we need to do is to load data and pass it to our components.

Two questions from here:

  1. What is the best way to load data in our NextJS application and pass it to Builder (export const getStaticPaths: GetStaticPaths = builderIoPaths('product', true)) ?
  2. Can we use different templates depending on the data that was loaded (we want to have different styles for different groups of products, yet keeping the same URL structure) ?

Hi @termosa :wave:

Our next-js starters/resources and React SDK may be helpful. There are also a few examples of asynchronous data fetching here. Let us know if you have any additional questions after you check these out!