-
Notifications
You must be signed in to change notification settings - Fork 27.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Docs: Document
windowHistorySupport
flag, and add pushState
/`repl…
…aceState` examples (#60374)
- Loading branch information
1 parent
ca5bc98
commit 496e38c
Showing
2 changed files
with
130 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
docs/02-app/02-api-reference/05-next-config-js/windowHistorySupport.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
title: webVitalsAttribution | ||
description: Learn how to use the webVitalsAttribution option to pinpoint the source of Web Vitals issues. | ||
--- | ||
|
||
`windowHistorySupport` is an experimental flag that allows you manually call [`window.history.pushState`](https://developer.mozilla.org/en-US/docs/Web/API/History/pushState) and [`window.history.replaceState`](https://developer.mozilla.org/en-US/docs/Web/API/History/replaceState). | ||
|
||
When the flag is enabled, `pushState` and `replaceState` calls are integrated into the Next.js Router, allowing you to sync with [`usePathname`](/docs/app/api-reference/functions/use-pathname) and [`useSearchParams`](/docs/app/api-reference/functions/use-search-params). | ||
|
||
To use it, set `windowHistorySupport` to `true` in your `next.config.js` file: | ||
|
||
```js fileName="next.config.js" | ||
module.exports = { | ||
experimental: { | ||
windowHistorySupport: true, | ||
}, | ||
} | ||
``` | ||
|
||
See the [Linking and Navigation](/docs/app/building-your-application/routing/linking-and-navigating#using-the-native-history-api) documentation for examples. |