Rockafella96
Rockafella96

Reputation: 31

How to dynamically create pages using sanity and next js?

I just watched this video on youtube, where we can see that a preview of the page is being instantly dynamically generated within the studio, while the person is adding the components randomly from the dropdown and editing its content.

What I want to know:

Is this dynamic generation limited to just the preview generation, or is the new page actually created dynamically on the nextjs frontend, with the components that person is adding to page structure randomly ?

I'm very new to react, nextjs, and the whole headless cms concept... and to be honest its a bit overwhelming handling all of this at once

If anyone can shed some more light on this, please do!

Thanks,

I have been able to create individual templates with re-usable components. But I haven't able to achieve what's shown in the video.

For my current setup, if somebody is creating a page structure on sanity studio using the re-usable components, I'll still have to create a new template for the newly created page structure, to query and display the components accordingly

Upvotes: 3

Views: 1061

Answers (1)

Steven
Steven

Reputation: 538

I might be wrong but from what I've seen, he has a set of ready components (e.g Hero Section component, Open text section, Product section, etc.) then in his dynamic page say for an example pages/[...slug.tsx] he fetches those Page document using the slug (e.g slug == 'home' then it fetches data from the home document) from his Sanity Studio then renders each component that's in the data which basically makes the whole page.

Upvotes: 0

Related Questions