Does static pre-rendering work for dynamic routes?
Hey all! Couple feasibility questions here:
1. Does pre-rendering work on dynamic routes which require data loading? I’m coming from Astro where we have getStaticPaths().
2. Do the exported static routes retain beforeLoad functionality? (Auth checks, etc)
Apologies if this has been answered elsewhere. I’ve tried to search this channel and check the docs but they seem vague on specifics.
8 Replies
extended-salmon•2mo ago
Does pre-rendering work on dynamic routes which require data loading?what exactly is that? a route with a loader?
eastern-cyanOP•2mo ago
Yes, essentially I have [productId].tsx that uses the url param to fetch product data for different items in the loader and passes them through to the route component so they can be SSR’d. I’m asking if pre-rendering can create X number of product pages or if it should be only used for purely static pages like the landing page or FAQ pages, etc
extended-salmon•2mo ago
cc @Tanner Linsley
xenial-black•2mo ago
Yes that’s the point. If it shows up for SSR, it will prerender
eastern-cyanOP•2mo ago
Hi tanner! Thanks for replying. Just to clarify, how would I provide the set of ids that it should pre-render for? Unless I’m mistaken, wouldn’t static pre-rendering work by generating the html at build time? In which case, we’d have to provide the list of productIds we want the loader to use?
xenial-black•2mo ago
It’s all driven by urls. So you would either need links somewhere that get crawled, or you can supply pages: [] to the plugin with URLs
eastern-cyanOP•2mo ago
Perfect, pages[] is the way for me. Thank you!
exotic-emerald•3d ago
Hey @stub , were you able to figure out how to make it work?