Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getInitialProps is being called client side with Automatic Static Optimization disabled #10546

Closed
dijs opened this issue Feb 16, 2020 · 2 comments

Comments

@dijs
Copy link
Contributor

dijs commented Feb 16, 2020

Bug report

Describe the bug

When a user navigates back/forward in history, getInitialProps is being called on the client-side which throws an error.

Unless I am misunderstanding something, this should never be called when Automatic Static Optimization is disabled, since all pages should be server side rendered.

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. Disable Automatic Static Optimization
  2. Load page with getInitialProps
  3. Navigate away and back
  4. See error

Expected behavior

Should not call getInitialProps client side

System information

  • Version of Next.js: 9.2.1
@lfades
Copy link
Member

lfades commented Feb 17, 2020

getInitialProps is called in the browser for client-side navigations with Link and next/router; and in the server for the first render, so such behavior is expected.

You may want to check for getServerProps, currently experimental: #9524 - but it will be released very soon.

@lfades lfades closed this as completed Feb 17, 2020
@balazsorban44
Copy link
Member

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.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants