Get to know MDN better
This feature is not Baseline because it does not work in some of the most widely-used browsers.
The redirect() method of the NavigationPrecommitController interface redirects the browser to a specified URL and specifies history behavior and any desired state information.
The URL to redirect to.
options OptionalAn options object, the properties of which can include:
state OptionalContains any state information you want to pass along with the navigation; for example, for logging or tracking purposes. This can be represented by any value type. The state for the navigation can subsequently be retrieved via the NavigationHistoryEntry.getState() method of the resulting history entry.
history OptionalAn enumerated value that specifies how this redirect should be added to the navigation history. It can take one of the following values:
autoThe default value, which lets the browser decide how to handle it:
Adds a new NavigationHistoryEntry to the navigation history, and clears any available forward navigation (that is, if the user previously navigated to other locations, then used the back button to return back through the history before initiating the navigation that caused the redirect).
replaceReplaces the Navigation.currentEntry with the resulting new NavigationHistoryEntry.
Note: The redirect() method can convert the history behavior between auto, push, and replace, but it cannot turn a traverse navigation into a push/replace navigation and vice versa.
None (undefined).
Thrown if:
Thrown if the specified url is invalid.
SecurityError DOMExceptionThrown if the current document is unable to have its URL rewritten to the provided redirect url.
See the main NavigationPrecommitController page for an example.
| HTML # dom-navigationprecommitcontroller-redirect |
Enable JavaScript to view this browser compatibility table.
This page was last modified on Dec 11, 2025 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.