JavaScriptEasy
How do you use window.history API?
By FrontendPro Editorial Team Updated 8/8/2026
#JavaScript
Answer
The window.history API allows you to manipulate the browser's session history. You can use history.pushState() to add a new entry to the history stack, history.replaceState() to modify the current entry, and history.back(), history.forward(), and history.go() to navigate through the history. For example, history.pushState({page: 1}, "title 1", "?page=1") adds a new entry to the history.
