SSG + CSR + dynamic pathing support
See original GitHub issueFeature request
Is your feature request related to a problem? Please describe.
It would be extremely useful to be able to statically generate and export a Next app while also having CSR functionality. For example, some apps have paths which don’t need to be static generated such as /products/783fdd81ca7da6845a0881ee716adc44
in an internal admin application. It’s certainly possible to rebuild the app each time a new product is published, but this is impractical with tens of thousands of products, and a dynamic URL parameter would be preferable.
Describe the solution you’d like
Something along the lines of getStaticPaths
but for client-side only.
Describe alternatives you’ve considered
Create React App, but no this does not come with SSG…and Next.js is so much better.
SSR, but this requires a server. Hosting purely on a CDN is ideal.
Additional context
Here is a prototype that uses both Next.js and React Router. Routes are defined in _app.js with Component
as the default route. This page can render given a dynamic URL parameter such as /products/5695088daab72366267e348ebc125e01
. Here is a hosted example.
Note that Index Document and Error Document are set to index.html
for the S3 bucket static website hosting settings. So when visiting /products/783fdd81ca7da6845a0881ee716adc44
, it falls back to the root /index.html file which picks up routing on the client side.
It would be really, really great if there was built-in support for client-side only routes with statically-generated and exported Next apps hosted via CDN. I feel this is a big thing missing from Next.js.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:4
- Comments:6 (1 by maintainers)
Top GitHub Comments
Hello @chaddjohnson and @braveforest, I have trouble understanding your exact issue using what nextJs already provides.
For SSG routes, you don’t need to “rebuild the app each time a new product is published”, the
fallback: true
param is there for that: https://nextjs.org/docs/basic-features/data-fetching#the-fallback-key-required You might also look into this: https://nextjs.org/blog/next-9-4#incremental-static-regeneration-betaAnd for pure CSR routes… well if you don’t use getStaticProps or getServerProps and do everything in the lifecycle of the component, it is a pure CSR route then, no?
Does this answer the question? Is there something in your needs that I did not understand?
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.