Next.js Discord

Discord Forum

Future of NextJS SSG (self-hosted application)

Unanswered
West African Lion posted this in #help-forum
Open in Discord
West African LionOP
Hey everyone we are working with NextJS in a lot of our projects and the more I started using the "new" app router features and especially the new caching logic I was thinking what the future of real SSG pages are in NextJS

My gut feeling is that - especially with tag based invalidation - shifting caching closer to data level logic (like fetching CMS data ) is better than statically generated pages. The biggest pain-point with SSG (self-hosted nextjs) we had in the past is when generating a lot of pages over the time restating / scaling the NextJS application takes longer and longer the more pages have been generated and you would have to build a deletion mechanism to not flood the file system.

This, and the fact that swr cache header in nextjs is not valid in a lot of common CDNs (like Azure Frontdoor) seem to be a good reason to me to really bet on api level caching and SSR rather than SSG.

What do you guys think? Glad to hear some oppinions about it 🙂

6 Replies

Ok so ssg isn't the best when your building a metric ton of pages, usually you don't even need all those pages built at once
What you can do is build the most viewed stuff with ssg
And the rest you can just ssr and cache it heavily
Do stuff like active preloading in menus and stuff
For the extra pages
Helps with both build times and also dosent have a major effect on speed