Documentation: Chrome History API
A promise-based wrapper for the Chrome history API to manage browser history.
- isAvailableHistory()
- addHistoryUrl(url)
- deleteAllHistory()
- deleteRangeHistory(range)
- deleteHistoryUrl(details)
- getHistoryVisits(url)
- searchHistory(query)
isAvailableHistory(method?: ApiMethodName<typeof chrome.history>): booleanThe optional method is a native function name, for example isAvailableHistory("search").
Import the public ApiMethodName type from @addon-core/browser for your own typed helpers.
This checks callable presence without invoking the method; permissions and argument support still require handling.
Returns true when the history namespace is present on the API selected by browser() in the current context.
Returns false if the namespace or WebExtension environment is absent, or if accessing it throws.
The check is synchronous, does not log, and reads the current API on every call without caching.
Without an argument, it checks namespace presence only. Pass a native method name to also check that it is callable.
Neither form verifies permissions, argument support, or a successful operation. See method availability.
import {isAvailableHistory} from "@addon-core/browser";
if (isAvailableHistory()) {
// The namespace is present; handle operation-specific failures when using it.
}addHistoryUrl(url: string): Promise<void>
Adds the specified URL to the browser history.
deleteAllHistory(): Promise<void>
Deletes all entries from the browser history.
deleteRangeHistory(range: chrome.history.Range): Promise<void>
Removes all history entries within the specified time range.
deleteHistoryUrl(details: chrome.history.UrlDetails): Promise<void>
Deletes all occurrences of the given URL from the history.
getHistoryVisits(url: string): Promise<chrome.history.VisitItem[]>
Retrieves the visit history for the specified URL.
searchHistory(query: chrome.history.HistoryQuery): Promise<chrome.history.HistoryItem[]>
Searches the browser history with the given query, returning matching history items.
onHistoryVisited(callback: (result: chrome.history.HistoryItem) => void): () => void
Adds a listener triggered when the browser records a page visit. Returns an unsubscribe function.
onHistoryVisitRemoved(callback: (removed: chrome.history.RemovedResult) => void): () => void
Adds a listener triggered when URLs are removed from the history, providing details of the removal. Returns an unsubscribe function.