Support for deferred static path resolution at runtime #81017
TahirMontgomery
started this conversation in
Ideas
Replies: 1 comment 4 replies
-
Doesn't returning an empty array in It means, keep this open for runtime requests. Then within This one uses blocking though, but same idea. |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Goals
Non-Goals
Background
In projects where we have a lot of dynamic content, like user profiles, marketplace listings, or blog posts, using getStaticPaths starts to break down at scale. Once you cross a few thousand pages, build times can balloon, sometimes taking 30 minutes to hours. This becomes a major bottleneck for teams that want to keep shipping fast or frequently.
For a SaaS with potentially thousands of pages, we don't need all of those pages pre-rendered at build time, but we do want them eventually static and cached, without having to pay the cold-start penalty of SSR or using fallback for each one.
Right now, there isn’t a great middle ground between building everything upfront with getStaticPaths and handling everything on-demand with SSR. I think there’s an opportunity to give developers more flexibility.
Proposal
The idea is to introduce a new optional function called getAsyncStaticPaths, which works just like getStaticPaths — except it doesn’t run at build time. Instead, it would run when the app boots up, or lazily on the first request to the route.
This lets developers skip the slow build process while still eventually generating all their pages as static files. Those pages could be cached just like any other SSG page, and the paths could be updated periodically behind the scenes (maybe with a revalidate option).
I’d love to help contribute! While I don’t have much experience contributing to large open source projects yet, I’m comfortable with TypeScript and willing to dig in. I’d appreciate guidance or direction from the maintainers if this moves forward, but I’m happy to help however I can
Beta Was this translation helpful? Give feedback.
All reactions