getStaticProps with { fallback: true } is very slow when spa routing.
See original GitHub issueBug report
Describe the bug
getStaticProps
with fallback: true
, NextJS send json response to client after calling getStaticProps
in server. In my case it takes 2s until the json response comes to browser in vercel production environment in spite of getStatipProps
finishing in 100ms. This may be caused by the json response is sent after the ssg rendering in server, I think the json must be returned just after getStatiProps
finished.
To Reproduce
- Use
getStatipProps
andgetStaticPaths
withfallback: true
- Request ssg page from browser.
- When ssg page loaded, navigate to another dynamic routing page with
next/link
ornext/router
. - See the chrome dev tool to see network response.
Expected behavior
The json response returned just after getStaticProps
finished in server, and SSG redering and caching is done in server after that.
Screenshots
System information
- OS: macOS, Vercel server.
- Browser (if applies): chrome
- Version of Next.js: 9.4.2
- Version of Node.js: latest
Issue Analytics
- State:
- Created 3 years ago
- Reactions:71
- Comments:35 (3 by maintainers)
Top Results From Across the Web
NextJS & json-server loading slow on localhost using ...
Just then getStaticProps will be called and your page rendered. In production it will be different, because it will only build at "build...
Read more >Next.js: The Good, Bad and Ugly - An Idiosyncratic Blog
fallback : true : when a request is made to a page that hasn't been generated, Next.js will immediately serve a static page...
Read more >Optimizing getStaticPaths() build times with the fallback property
The fallback property of getStaticPaths() has three values: false, true, & blocking. Learn how to use the fallback property to improve your ...
Read more >Eliminating Next.js ISR Builds with Client Side Rendering
In a nutshell, ISR lets you create new static pages on the fly. ... fallback: true }}export async function getStaticProps({ params }) ...
Read more >SSR vs SSG in Next.js – a practical overview for CTOs and devs
Server-side rendering and static site generation are both useful for improving app ... That made SPAs very difficult to index properly.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Still the same problem with next 12.0.1 very slow in dev when getStaticPaths is used in a page.
This is still an ongoing issue, any update?