nextjs - ✅(Solved) Fix Docs: `getInitialProps` does not behave as explained in the docs [1 pull requests, 7 comments, 3 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
vercel/next.js#86386Fetched 2026-04-08 02:11:15
View on GitHub
Comments
7
Participants
3
Timeline
20
Reactions
0
Timeline (top)
commented ×7mentioned ×3subscribed ×3referenced ×2

Fix Action

Fixed

PR fix notes

PR #86387: docs: fix getInitialProps execution behavior during navigation

Description (problem / solution / changelog)

Closes https://github.com/vercel/next.js/issues/86386

<!-- Thanks for opening a PR! Your contribution is much appreciated. To make sure your PR is handled as smoothly as possible we request that you follow the checklist sections below. Choose the right checklist for the change(s) that you're making: ## For Contributors ### Improving Documentation - Run `pnpm prettier-fix` to fix formatting issues before opening the PR. - Read the Docs Contribution Guide to ensure your contribution follows the docs guidelines: https://nextjs.org/docs/community/contribution-guide ### Fixing a bug - Related issues linked using `fixes #number` - Tests added. See: https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs - Errors have a helpful link attached, see https://github.com/vercel/next.js/blob/canary/contributing.md ### Adding a feature - Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. (A discussion must be opened, see https://github.com/vercel/next.js/discussions/new?category=ideas) - Related issues/discussions are linked using `fixes #number` - e2e tests added (https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs) - Documentation added - Telemetry added. In case of a feature if it's used or not. - Errors have a helpful link attached, see https://github.com/vercel/next.js/blob/canary/contributing.md ## For Maintainers - Minimal description (aim for explaining to someone not on the team to understand the PR) - When linking to a Slack thread, you might want to share details of the conclusion - Link both the Linear (Fixes NEXT-xxx) and the GitHub issues - Add review comments if necessary to explain to the reviewer the logic behind a change ### What? ### Why? ### How? Closes NEXT- Fixes # -->

Changed files

  • docs/02-pages/04-api-reference/03-functions/get-initial-props.mdx (modified, +1/-1)

Code Example

when navigating to different pages:

if page being navigated to DOES NOT have getServerSideProps:
- getInitialProps runs only on clientSide and does not run on serverSide

if page being navigated to DOES have getServerSideProps:
- getInitialProps and getServerSideProps runs only on serverSide, does not run on clientSide
RAW_BUFFERClick to expand / collapse

What is the documentation issue?

The below snippets taken from get-initial-props doc page do not accurately represent the behavior of getInitialProps as of next version 16.0.3

getInitialProps is an async function that can be added to the default exported React component for the page. It will run on both the server-side and again on the client-side during page transitions. The result of the function will be forwarded to the React component as props.

and:

Good to know:

  • Data returned from getInitialProps is serialized when server rendering. Ensure the returned object from getInitialProps is a plain Object, and not using Date, Map or Set.
  • For the initial page load, getInitialProps will run on the server only. getInitialProps will then also run on the client when navigating to a different route with the next/link component or by using next/router.
  • If getInitialProps is used in a custom _app.js, and the page being navigated to is using getServerSideProps, then getInitialProps will also run on the server.

Here are my findings that I tested locally:

when navigating to different pages:

if page being navigated to DOES NOT have getServerSideProps:
- getInitialProps runs only on clientSide and does not run on serverSide

if page being navigated to DOES have getServerSideProps:
- getInitialProps and getServerSideProps runs only on serverSide, does not run on clientSide

The documentation needs to be amended to consider this.

Is there any context that might help us understand?

you can test this locally yourself, initiate a nextjs project and try it out.

Does the docs page already exist? Please link to it.

https://github.com/vercel/next.js/blob/36f50c5a11cdd92953f711fca5fadbbe6033ec8a/docs/02-pages/04-api-reference/03-functions/get-initial-props.mdx#L4

extent analysis

TL;DR

The documentation for getInitialProps in Next.js needs to be updated to reflect its actual behavior, particularly regarding its execution on server-side and client-side during page transitions.

Guidance

  • Review the current documentation for getInitialProps and compare it with the locally tested findings to identify discrepancies.
  • Update the documentation to accurately describe the behavior of getInitialProps when navigating to pages with and without getServerSideProps.
  • Consider adding examples or notes to the documentation to clarify the execution of getInitialProps on server-side and client-side in different scenarios.
  • Test the updated documentation locally to ensure it accurately reflects the behavior of getInitialProps in Next.js version 16.0.3.

Example

No code snippet is provided as the issue is related to documentation accuracy rather than code implementation.

Notes

The issue is specific to the documentation of getInitialProps in Next.js version 16.0.3, and the suggested updates should be verified through local testing to ensure accuracy.

Recommendation

Apply workaround: Update the documentation to reflect the actual behavior of getInitialProps as described in the issue, to ensure that developers have accurate information when using this function in their Next.js projects.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

nextjs - ✅(Solved) Fix Docs: `getInitialProps` does not behave as explained in the docs [1 pull requests, 7 comments, 3 participants]