Gatsby: How to use dynamic pages in GatsbyJS?

Created on 10 Dec 2018  路  2Comments  路  Source: gatsbyjs/gatsby

I already use Gatsby before but only for static content. I love it.

That's why now, I would like to use Gatsby for dynamic content.

How/Where should I start?

I already read the doc of Gatsby about client-only, but I don't really understand.
Is there something more? Starters, tutorials?

Thanks

question or discussion

Most helpful comment

In case of static content (that you've already built), Gatsby generates HTML for all the pages at build time (which is one of the things that makes it so fast).

With dynamic content, since there is no way of knowing what to generate at build time (it _is_ dynamic), you can just go ahead and render any React components like you normally would at runtime _dynamically_. This is as true for Gatsby as any plain React app 馃檪

The only special thing Gatsby needs to know for client side routes is what path prefix is for a client side route. You can use this plugin to tell Gatsby that.

Check out

I'm closing this for now but please feel free to reopen if there is anything else. Thank you and happy building!

All 2 comments

@Steffi3rd the best advice i can give you is break down the code on the client side routing, then with that and the gatsby docs opened, and some react docs also that might come in handy. start commenting out the code in and out and see what is happening and start taking notes on the process.
To give you a boost the starters page is here and the examples here, but before deep diving into a google search for dynamic content with any type data retrieval and build, go over this first. Go over them at your own pace, don't rush it and try to understand it. Once you're familiar with the way gatstby gets things done, the next move is a cake walk

In case of static content (that you've already built), Gatsby generates HTML for all the pages at build time (which is one of the things that makes it so fast).

With dynamic content, since there is no way of knowing what to generate at build time (it _is_ dynamic), you can just go ahead and render any React components like you normally would at runtime _dynamically_. This is as true for Gatsby as any plain React app 馃檪

The only special thing Gatsby needs to know for client side routes is what path prefix is for a client side route. You can use this plugin to tell Gatsby that.

Check out

I'm closing this for now but please feel free to reopen if there is anything else. Thank you and happy building!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mikestopcontinues picture mikestopcontinues  路  3Comments

ghost picture ghost  路  3Comments

theduke picture theduke  路  3Comments

kalinchernev picture kalinchernev  路  3Comments

signalwerk picture signalwerk  路  3Comments