# History API

Category: [Rendering & JavaScript](https://seo-geo-glossary.com/en/glossary/category/rendering-javascript/) › [JavaScript & frameworks](https://seo-geo-glossary.com/en/glossary/category/rendering-javascript/javascript-frameworks/)

The **History API** is a browser interface through which JavaScript reads and changes the session history of a tab. The name also belongs to many unrelated product APIs. This entry covers the browser interface. With `pushState()` a script adds a history entry, optionally with a new URL, and the page does not reload.

## How does the History API work?
`pushState(state, unused, url)` takes a serializable state object, a parameter that exists for historical reasons, and an optional URL. The browser does not attempt to load that URL after the call. The URL must have the same origin as the current one, otherwise `pushState()` throws an exception. When the user moves through the history, a `popstate` event fires. Unlike setting `window.location` to a hash, `pushState()` never fires `hashchange`. `replaceState()` replaces the current entry instead of adding one.

## What does it mean for SEO?
Single-page applications switch views with JavaScript. Google recommends the History API for routing between views and advises against using URL fragments to load different content, because Googlebot cannot reliably resolve them. In its example, links are normal `<a href="/products">` elements and the script calls `pushState()` on click.

Since every such URL can also be requested directly, for example after a reload or by a crawler, the server should be able to answer it with the page and a fitting status code (assessment).

## Example
```javascript
const url = new URL(location);
url.pathname = "/shoes/sneakers";
history.pushState({}, "", url);
```

The address bar shows `/shoes/sneakers`, and the page did not reload.

## Related terms

- [Single-page application](https://seo-geo-glossary.com/en/glossary/single-page-application/index.md)
- [Hash URLs](https://seo-geo-glossary.com/en/glossary/hash-urls/index.md)
- [Fragment identifier](https://seo-geo-glossary.com/en/glossary/fragment-identifier/index.md)
- [JavaScript SEO](https://seo-geo-glossary.com/en/glossary/javascript-seo/index.md)
- [Client-side rendering](https://seo-geo-glossary.com/en/glossary/client-side-rendering/index.md)
- [Rendering](https://seo-geo-glossary.com/en/glossary/rendering/index.md)

## Sources

- [History API – MDN](https://developer.mozilla.org/en-US/docs/Web/API/History_API)
- [History: pushState() – MDN](https://developer.mozilla.org/en-US/docs/Web/API/History/pushState)
- [Fix Search-related JavaScript problems – Google Search Central](https://developers.google.com/search/docs/crawling-indexing/javascript/fix-search-javascript)

---

Last updated: October 7, 2026
URL: https://seo-geo-glossary.com/en/glossary/history-api/
