Use the history API to interact with the browser history.

Note that downloads are treated as HistoryItem objects. Therefore, events such as history.onVisited will also fire for downloads.

Browser history is a chronological record of pages the user has visited. The history API enables you to:

However, the user may have visited a single page multiple times, so the API also has the concept of "visits". So you can also use this API to:

To use this API, an extension must request the "history" permission in its manifest.json file.

Types

history.TransitionType
Describes how the browser navigated to a particular page.
history.HistoryItem

Provides information about a particular page in the browser history.

history.VisitItem

Describes a single visit to a page.

Functions

history.search()
Searches the browser history for history.HistoryItem objects matching the given criteria.
history.getVisits()
Retrieves information about visits to a given page.
history.addUrl()
Adds a record to the browser history of a visit to the given page.
history.deleteUrl()
Removes all visits to the given URL from the browser history.
history.deleteRange()
Removes all visits to pages that the user made during the given time range.
history.deleteAll()
Removes all visits from the browser history.

Events

history.onTitleChanged
Fired when the title of a page visited by the user is recorded.
history.onVisited
Fired each time the user visits a page, providing the history.HistoryItem data for that page.
history.onVisitRemoved

Fired when a URL is removed completely from the browser history.

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxOperaFirefox for Android
HistoryItemChrome Full support YesEdge No support NoFirefox Full support 49Opera Full support YesFirefox Android No support No
TransitionTypeChrome Full support YesEdge No support NoFirefox Full support 50Opera Full support YesFirefox Android No support No
VisitItemChrome Full support YesEdge No support NoFirefox Full support 50Opera Full support YesFirefox Android No support No
addUrlChrome Full support YesEdge No support NoFirefox Full support 49Opera Full support YesFirefox Android No support No
deleteAllChrome Full support YesEdge No support NoFirefox Full support 49Opera Full support YesFirefox Android No support No
deleteRangeChrome Full support YesEdge No support NoFirefox Full support 49Opera Full support YesFirefox Android No support No
deleteUrlChrome Full support YesEdge No support NoFirefox Full support 49Opera Full support YesFirefox Android No support No
getVisitsChrome Full support YesEdge No support NoFirefox Full support 50Opera Full support YesFirefox Android No support No
onTitleChangedChrome No support NoEdge No support NoFirefox Full support 55Opera No support NoFirefox Android No support No
onVisitRemovedChrome Full support YesEdge No support NoFirefox Full support 50Opera Full support YesFirefox Android No support No
onVisitedChrome Full support YesEdge No support NoFirefox Full support 50
Notes
Full support 50
Notes
Notes Before version 56, the result object's 'title' was always an empty string. From version 56 onwards, it is set to the last known title, if that is available, or an empty string otherwise.
Opera Full support YesFirefox Android No support No
searchChrome Full support YesEdge No support NoFirefox Full support 49Opera Full support YesFirefox Android No support No

Legend

Full support  
Full support
No support  
No support
See implementation notes.
See implementation notes.

Example extensions

Acknowledgements

This API is based on Chromium's chrome.history API. This documentation is derived from history.json in the Chromium code.

Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.

Document Tags and Contributors

Contributors to this page: wbamberg, andrewtruongmoz, Sheppy, mwein
Last updated by: wbamberg,