getInitialProps run on server even when routed with Link
See original GitHub issueBug report
Describe the bug
getInitialProps
should not run on the server when page is accessed when clicking a Link
,
To Reproduce
Steps to reproduce the behavior, please provide code snippets or a repository:
- Go to https://codesandbox.io/s/getinitialprops-runs-on-server-client-9o5dp
- Click on ‘About via Client Side’
- See in server console is “is server”
Expected behavior
Should show “is client” in client console and not “is server” on Link click.
System information
- OS: macOs
- Version of Next.js: 9.0.3
Additional context
I think this regression happened in 9.x version. This does not happen every time. Sometimes you need to go back to / and try again.
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
getInitialProps run on server even when routed with Link #8242
Bug report Describe the bug getInitialProps should not run on the server when page is accessed when clicking a Link, To Reproduce Steps...
Read more >NextJS - only run getInitialProps if route is different
All is working fine, but I noticed that if I click the same link twice, getInitialProps runs again, even though everything is the...
Read more >getInitialProps - Data Fetching - Next.js
For the initial page load, getInitialProps will run on the server only. getInitialProps will then run on the client when navigating to a...
Read more >Why I Got Rid of getInitialProps in My Next.js Project
In Next.js, getInitialProps enables server-side rendering and can't be statically optimized. It runs every time we open a page.
Read more >Next.js Server Side Rendering and getInitialProps - YouTube
5:34 - Code in Next.js will be run both on the server side as well as the ... If, however, you route to...
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
Your sandbox does exactly this.
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.