---
title: "History | JavaScript maps SDK"
description: "Documentation for MapTiler SDK"
---

> For AI agents: a documentation index is available at [/llms.txt](https://docs.maptiler.com/llms.txt). Markdown versions of all pages are available by appending .md to any URL.

# Interface History

The **`History`** interface of the History API allows manipulation of the browser session history, that is the pages visited in the tab or frame that the current page is loaded in.

[MDN Reference](https://developer.mozilla.org/docs/Web/API/History)

interface History {  
    [length](#length): number;  
    [scrollRestoration](#scrollrestoration): [ScrollRestoration](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.ScrollRestoration/);  
    [state](#state): any;  
    [back](#back-1)(): void;  
    [forward](#forward-1)(): void;  
    [go](#go-1)(delta?: number): void;  
    [pushState](#pushstate-1)(data: any, unused: string, url?: string | URL | null): void;  
    [replaceState](#replacestate-1)(data: any, unused: string, url?: string | URL | null): void;  
}

##### Index

### Properties[](#properties)

[length](#length) [scrollRestoration](#scrollrestoration) [state](#state)

### Methods[](#methods)

[back](#back) [forward](#forward) [go](#go) [pushState](#pushstate) [replaceState](#replacestate)

## Properties[](#properties-1)

### `Readonly`length[](#length)

length: number

The **`length`** read-only property of the History interface returns an integer representing the number of entries in the session history, including the currently loaded page.

[MDN Reference](https://developer.mozilla.org/docs/Web/API/History/length)

### scrollRestoration[](#scrollrestoration)

scrollRestoration: [ScrollRestoration](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.ScrollRestoration/)

The **`scrollRestoration`** property of the History interface allows web applications to explicitly set default scroll restoration behavior on history navigation.

[MDN Reference](https://developer.mozilla.org/docs/Web/API/History/scrollRestoration)

### `Readonly`state[](#state)

state: any

The **`state`** read-only property of the History interface returns a 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 popstate event.

[MDN Reference](https://developer.mozilla.org/docs/Web/API/History/state)

## Methods[](#methods-1)

### back[](#back)

-   back(): void[](#back-1)
    
    The **`back()`** method of the History interface causes the browser to move back one page in the session history.
    
    [MDN Reference](https://developer.mozilla.org/docs/Web/API/History/back)
    
    #### Returns void
    

### forward[](#forward)

-   forward(): void[](#forward-1)
    
    The **`forward()`** method of the History interface causes the browser to move forward one page in the session history. It has the same effect as calling history.go(1).
    
    [MDN Reference](https://developer.mozilla.org/docs/Web/API/History/forward)
    
    #### Returns void
    

### go[](#go)

-   go(delta?: number): void[](#go-1)
    
    The **`go()`** method of the History interface loads a specific page from the session history. You can use it to move forwards and backwards through the history depending on the value of a parameter.
    
    [MDN Reference](https://developer.mozilla.org/docs/Web/API/History/go)
    
    #### Parameters
    
    -   `Optional`delta: number
    
    #### Returns void
    

### pushState[](#pushstate)

-   pushState(data: any, unused: string, url?: string | URL | null): void[](#pushstate-1)
    
    The **`pushState()`** method of the History interface adds an entry to the browser's session history stack.
    
    [MDN Reference](https://developer.mozilla.org/docs/Web/API/History/pushState)
    
    #### Parameters
    
    -   data: any
    -   unused: string
    -   `Optional`url: string | URL | null
    
    #### Returns void
    

### replaceState[](#replacestate)

-   replaceState(data: any, unused: string, url?: string | URL | null): void[](#replacestate-1)
    
    The **`replaceState()`** method of the History interface modifies the current history entry, replacing it with the state object and URL passed in the method parameters. This method is particularly useful when you want to update the state object or URL of the current history entry in response to some user action.
    
    [MDN Reference](https://developer.mozilla.org/docs/Web/API/History/replaceState)
    
    #### Parameters
    
    -   data: any
    -   unused: string
    -   `Optional`url: string | URL | null
    
    #### Returns void
