Registry / web-framework / history-plus

history-plus

JSON →
library3.3.3jsnpmunverified

JavaScript library for managing browser session history anywhere JavaScript runs. Current stable version is v5.3.0 (2022-01-15, last release as of 2025). v5 is a complete rewrite with TypeScript support, breaking changes from v4/v3 including renamed exports (e.g., createBrowserHistory instead of createHistory) and removal of the createHistory function. Key differentiator: React Router's underlying history manager; abstracts differences between browser, hash, and memory history. Release cadence: infrequent, no recent activity. v4 is deprecated in favor of v5.

npm install history-plus
INSTALL
IMPORT
SIG · HISTORY-PLUS
H
history-plus
web-frameworkjavascriptv3.3.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

createBrowserHistory
import { createBrowserHistory } from 'history'
import { createHistory } from 'history'
v5 renamed createHistory to createBrowserHistory (or createHashHistory/createMemoryHistory). The old name does not exist in v5.
BrowserHistory
import type { BrowserHistory } from 'history'
import { BrowserHistory } from 'history'
BrowserHistory is a type, not a runtime value. In TypeScript, use `import type` for types. In v5, types are built-in.
Location
import { Location } from 'history'
import { Location } from 'react-router-dom'
Location type is exported from 'history' directly. In v5, the generic State parameter was removed; use `Location` with `unknown` or narrow yourself.

Creates a browser history, listens for location changes, and pushes a new entry with state.

import { createBrowserHistory } from 'history'; const history = createBrowserHistory(); const unlisten = history.listen(({ location, action }) => { console.log(action, location.pathname, location.state); }); history.push('/home', { user: 'johndoe' }); setTimeout(() => { unlisten(); }, 5000);
Debug
Known issues
breakingv5 removed the `createHistory` function; use `createBrowserHistory`, `createHashHistory`, or `createMemoryHistory`.
fix
Replace `createHistory` with `createBrowserHistory` (for HTML5 history) or the appropriate variant.
affects: >=5.0.0
breakingv5 removed the generic `State` parameter from `Location`. `location.state` is now `unknown`.
fix
Cast `location.state` to your expected type: `location.state as MyState`.
affects: >=5.0.0
deprecated`PartialPath` and `PartialLocation` types were deprecated in v5.2.0; use `Partial<Path>` and `Partial<Location>` instead.
fix
Replace `PartialPath` with `Partial<Path>` and `PartialLocation` with `Partial<Location>`.
affects: >=5.2.0
breakingv5 no longer includes a UMD build; it's now ESM and CJS only.
fix
Use a bundler (webpack, rollup, etc.) or import from ESM CDN like esm.sh: `import { createBrowserHistory } from 'https://esm.sh/history'`.
affects: >=5.0.0
deprecated`history.block` API changed: v4 returned a function, v5 returns an object with a `retry` method.
fix
Update blocking logic: use `const unblock = history.block(prompt);` and `unblock.retry()` to retry.
affects: >=5.0.0
Errors
Common errors & fixes
Uncaught TypeError: (0 , _history.createHistory) is not a function
Using `createHistory` from v5 which removed it.
fix
Use `createBrowserHistory` (or `createHashHistory`/`createMemoryHistory`) instead.
Module '"history"' has no exported member 'LocationState'.
In v5, LocationState type was removed; location.state type is now unknown.
fix
Remove references to LocationState; cast location.state as needed.
TS2339: Property 'block' does not exist on type 'BrowserHistory'
TypeScript types may be missing if using an outdated version; in v5, block() is available.
fix
Ensure you have history@5.0.0 or later. Import types: `import type { BrowserHistory } from 'history'`.
Upgrade
Version history
3.3.3latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
history-plus — npm install history-plus · libregistry