files/en-us/web/api/history/index.md
{{APIRef("History API")}}
The History interface of the {{domxref("History API", "", "", "nocode")}} allows manipulation of the browser session history, that is the pages visited in the tab or frame that the current page is loaded in.
There is only one instance of history (It is a singleton.) accessible via the global object {{domxref("Window.history", "history")}}.
[!NOTE] This interface is only available on the main thread ({{domxref("Window")}}). It cannot be accessed in {{domxref("Worker")}} or {{domxref("Worklet")}} contexts.
The History interface doesn't inherit any property.
Integer representing the number of elements in the session history, including the currently loaded page. For example, for a page loaded in a new tab this property returns 1.auto or manual.any value representing the state at the top of the history stack. This is a way to look at the state without having to wait for a {{domxref("Window/popstate_event", "popstate")}} event.The History interface doesn't inherit any methods.
{{domxref("History.back","back()")}}
: This asynchronous method goes to the previous page in session history, the same action as when the user clicks the browser's <kbd>Back</kbd> button. Equivalent to history.go(-1).
Calling this method to go back beyond the first page in the session history has no effect and doesn't raise an exception.
{{domxref("History.forward","forward()")}}
: This asynchronous method goes to the next page in session history, the same action as when the user clicks the browser's <kbd>Forward</kbd> button; this is equivalent to history.go(1).
Calling this method to go forward beyond the most recent page in the session history has no effect and doesn't raise an exception.
{{domxref("History.go","go()")}}
-1 for the previous page or 1 for the next page. If you specify an out-of-bounds value (for instance, specifying -1 when there are no previously-visited pages in the session history), this method silently has no effect. Calling go() without parameters or a value of 0 reloads the current page.{{domxref("History.pushState","pushState()")}}
{{domxref("History.replaceState","replaceState()")}}
{{Specifications}}
{{Compat}}