{"id":25728,"library":"history-plus","title":"history","description":"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.","status":"active","version":"3.3.3","language":"javascript","source_language":"en","source_url":"https://github.com/reacttraining/history","tags":["javascript","history","location"],"install":[{"cmd":"npm install history-plus","lang":"bash","label":"npm"},{"cmd":"yarn add history-plus","lang":"bash","label":"yarn"},{"cmd":"pnpm add history-plus","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"v5 renamed createHistory to createBrowserHistory (or createHashHistory/createMemoryHistory). The old name does not exist in v5.","wrong":"import { createHistory } from 'history'","symbol":"createBrowserHistory","correct":"import { createBrowserHistory } from 'history'"},{"note":"BrowserHistory is a type, not a runtime value. In TypeScript, use `import type` for types. In v5, types are built-in.","wrong":"import { BrowserHistory } from 'history'","symbol":"BrowserHistory","correct":"import type { BrowserHistory } from 'history'"},{"note":"Location type is exported from 'history' directly. In v5, the generic State parameter was removed; use `Location` with `unknown` or narrow yourself.","wrong":"import { Location } from 'react-router-dom'","symbol":"Location","correct":"import { Location } from 'history'"}],"quickstart":{"code":"import { createBrowserHistory } from 'history';\n\nconst history = createBrowserHistory();\n\nconst unlisten = history.listen(({ location, action }) => {\n  console.log(action, location.pathname, location.state);\n});\n\nhistory.push('/home', { user: 'johndoe' });\n\nsetTimeout(() => {\n  unlisten();\n}, 5000);","lang":"typescript","description":"Creates a browser history, listens for location changes, and pushes a new entry with state."},"warnings":[{"fix":"Replace `createHistory` with `createBrowserHistory` (for HTML5 history) or the appropriate variant.","message":"v5 removed the `createHistory` function; use `createBrowserHistory`, `createHashHistory`, or `createMemoryHistory`.","severity":"breaking","affected_versions":">=5.0.0"},{"fix":"Cast `location.state` to your expected type: `location.state as MyState`.","message":"v5 removed the generic `State` parameter from `Location`. `location.state` is now `unknown`.","severity":"breaking","affected_versions":">=5.0.0"},{"fix":"Replace `PartialPath` with `Partial<Path>` and `PartialLocation` with `Partial<Location>`.","message":"`PartialPath` and `PartialLocation` types were deprecated in v5.2.0; use `Partial<Path>` and `Partial<Location>` instead.","severity":"deprecated","affected_versions":">=5.2.0"},{"fix":"Use a bundler (webpack, rollup, etc.) or import from ESM CDN like esm.sh: `import { createBrowserHistory } from 'https://esm.sh/history'`.","message":"v5 no longer includes a UMD build; it's now ESM and CJS only.","severity":"breaking","affected_versions":">=5.0.0"},{"fix":"Update blocking logic: use `const unblock = history.block(prompt);` and `unblock.retry()` to retry.","message":"`history.block` API changed: v4 returned a function, v5 returns an object with a `retry` method.","severity":"deprecated","affected_versions":">=5.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use `createBrowserHistory` (or `createHashHistory`/`createMemoryHistory`) instead.","cause":"Using `createHistory` from v5 which removed it.","error":"Uncaught TypeError: (0 , _history.createHistory) is not a function"},{"fix":"Remove references to LocationState; cast location.state as needed.","cause":"In v5, LocationState type was removed; location.state type is now unknown.","error":"Module '\"history\"' has no exported member 'LocationState'."},{"fix":"Ensure you have history@5.0.0 or later. Import types: `import type { BrowserHistory } from 'history'`.","cause":"TypeScript types may be missing if using an outdated version; in v5, block() is available.","error":"TS2339: Property 'block' does not exist on type 'BrowserHistory'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}