question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SSG + CSR + dynamic pathing support

See original GitHub issue

Feature 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:closed
  • Created 3 years ago
  • Reactions:4
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
feycheniecommented, Jun 14, 2020

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-beta

And 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?

0reactions
balazsorban44commented, Jan 30, 2022

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Compare and Contrast: CSR, SSR, and SSG in NextJS
Static-site generation creates a number of static paths based on the data needed for the page. At build time, these many paths are...
Read more >
CSR / SSR / SSG / ISR with Next.js – Explained! - YouTube
Next.js is a hybrid framework, allowing you to choose your data fetching strategy on a per-page basis. Learn about all the different options ......
Read more >
CSR, SSR, and SSG on NextJS - YouTube
Let's take a single app and build it three ways, with client side rendering ( CSR ), server side rendering (SSR) and static...
Read more >
NEXT.js Crash Course | Dynamic SSG Pages with ... - YouTube
... learn about how to fetch data using Dynamic SSG pages with getStaticProps and getStaticPaths in Next.js and why it is useful. Support...
Read more >
What does CSR, SSR, SSG and ISR means and why should ...
NextJS offers 3 methods to generate pages on a server, this article will detail the benefits and drawbacks of each strategy to help...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found