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.

getInitialProps makes 404 and search render as SSR

See original GitHub issue

We’re using getInitialProps in _app.js to allow us to have a “global” data layer

Beyond the general recommendation to steer away from it to use newer methods, turns out if you use it and your page doesn’t use any other data fetching method, it assumes SSR

We need to add simple stubs of static props on any pages not using any data fetching simply to turn on static generation for those pages

export async function getStaticProps() {
  return {
    props: {},

Pages that need this added:

  • /search
  • /404

Please confirm by running build that all pages are statically generated

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

colbyfayockcommented, Oct 3, 2021

Go for it! All yours

On Sun, Oct 3, 2021 at 10:58 AM Peter Cruckshank @.***> wrote:

Hey Colby 🙋‍♂️ I would love to put in a fix for this issue.

It seems pretty straight forward, let me know if you want me to write up a PR for it 👍🏻



— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe . Triage notifications on the go with GitHub Mobile for iOS or Android


Read more comments on GitHub >

github_iconTop Results From Across the Web

Next.js return the 404 error page in getInitialProps
Next v10 allows to return 404 page (not with props, ... In order to do that, you'll have to render the Error page...
Read more >
Way to return 404 http error code in render() #4452 - GitHub
Right now you can return 404 http error code only in getInitialProps, which is not nice, since you have to fetch the data...
Read more >
How to return a 404 error in getServerSideProps with Next.js
To search engines, this essentially translates to: "Everything went fine and we found the page". Rather than actually responding with a 404 , ......
Read more >
What is Next.js getInitialProps and getServerSideProps? | refine
getInitialProps is an asynchronous function used for fetching data on the server and pre-rendering the resulting data (aka server-side rendering) ...
Read more >
getServerSideProps vs getInitialProps getStaticProps in Next.js
getInitialProps is used to enable Server-Side Rendering, or SSR for a page. With SSR, the HTML is generated on the server when it...
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 Post

No results found

github_iconTop Related Hashnode Post

No results found