PopStateEvent: state property

The state read-only property of the PopStateEvent interface represents the state stored when the event was created.

Practically it is a value provided by the call to history.pushState() or history.replaceState()


An object, or null.


The code below logs the value of state when using the pushState() method to push a value to the history.

// Log the state of
addEventListener("popstate", (event) => {
  console.log("State received: ", event.state);

// Now push something on the stack
history.pushState({ name: "Example" }, "pushState example", "page1.html");
  { name: "Another example" },
  "pushState example",

This will log:

State received: { name: "Example" }
State received: { name: "Another example" }


HTML Standard
# dom-popstateevent-state-dev

Browser compatibility

BCD tables only load in the browser

See also