T
TanStack13mo ago
like-gold

Automatically SSG

https://tanstack.com/router/latest/docs/framework/react/start/static-prerendering According to the document, @tanstack/start needs manually configuration for SSG. Can it be done automatically like NextJS in the future?
Static Prerendering | TanStack Router React Docs
Static Prerendering is a feature of Nitro, and while it is available in TanStack Start, we are still exploring the best practices for using it. Tread lightly! Static prerendering is the process of generating static HTML files for your application. This can be useful for either improving the performance of your application, as it allows you to s...
10 Replies
foreign-sapphire
foreign-sapphire13mo ago
Potentially.
clever-tan
clever-tan4mo ago
Im curious how to use the prerendering option with the new alpha channel to render an entire website based on a headless CMS. I used the NextJS pages folder with getStaticPaths and getStaticProps. So far I understood I could have a
// routes/$.tsx => catch all component for the page
// routes/$.tsx => catch all component for the page
How would I create all the dynamic paths to have all pages pre-rendered (SSG)? Is hooks:"prerender:routes" the equivalent of getStaticPaths? Does this work with the devinxi branch currently? Would be great to see an example. NextJS pushes so hard the app folder - the pages folder does not get so much attention any longer.
correct-apricot
correct-apricot4mo ago
I used static server actions for this it and it works quite well for static data loading, though that isn’t quite the same as true SSG In my case, having “SSR but static data” is good enough since the SSR works well with Cloudflare workers
clever-tan
clever-tan4mo ago
For me only true SSG matters - the enduser should never reach a server API, it should only see prerendered HTML, CSS and JS - only that approach really flies fast and also keeps the API calls to server limited
correct-apricot
correct-apricot4mo ago
SSR of Start seems to be just as fast as far as I can tell, but yeah depending on how you’re hosting that could be true.
clever-tan
clever-tan4mo ago
I would most likely reach quickly the monthly API call limit if users would call the server. I am on Vercel at the moment - could look into Cloudflare as an alternative. But yeah - I really think for websites true SSG matters
foreign-sapphire
foreign-sapphire4mo ago
You can use spa mode with pre-rendering and ship fully static. You can even put server functions into static mode and turn them into json files at build time.
clever-tan
clever-tan4mo ago
that sounds terrific.. but how? is there any example available? i think that would be a great candidate for a migration guide NextJS SSG => TStart SSG, Ive seen the migration guide but that currently covers mostly SSR
fascinating-indigo
fascinating-indigo4mo ago
Do you use alpha version ?
foreign-sapphire
foreign-sapphire4mo ago
There is a start static example on the alpha branch

Did you find this page helpful?