createBrowserHistory

external fun createBrowserHistory(opts: CreateBrowserHistoryOpts = definedExternally): RouterHistory(source)

Creates a history object that can be used to interact with the browser's navigation. This is a lightweight API wrapping the browser's native methods. It is designed to work with TanStack Router, but could be used as a standalone API as well. IMPORTANT: This API implements history throttling via a microtask to prevent excessive calls to the history API. In some browsers, calling history.pushState or history.replaceState in quick succession can cause the browser to ignore subsequent calls. This API smooths out those differences and ensures that your application state will eventually match the browser state. In most cases, this is not a problem, but if you need to ensure that the browser state is up to date, you can use the history.flush method to immediately flush all pending state changes to the browser URL.

Parameters

opts
opts.getHref

A function that returns the current href (path + search + hash)

opts.createHref

A function that takes a path and returns a href (path + search + hash)