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.

getStaticProps with { fallback: true } is very slow when spa routing.

See original GitHub issue

Bug 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

  1. Use getStatipProps and getStaticPaths with fallback: true
  2. Request ssg page from browser.
  3. When ssg page loaded, navigate to another dynamic routing page with next/link or next/router.
  4. 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:open
  • Created 3 years ago
  • Reactions:71
  • Comments:35 (3 by maintainers)

github_iconTop GitHub Comments

19reactions
remyb-devcommented, Oct 31, 2021

Still the same problem with next 12.0.1 very slow in dev when getStaticPaths is used in a page.

8reactions
alepachecocommented, Jul 13, 2022

This is still an ongoing issue, any update?

Read more comments on GitHub >

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

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