A JavaScript library for managing session history in any JavaScript environment. Version 2.1.1 (stable) provides a minimal API to manage the history stack, navigate, confirm navigation, and persist state. It abstracts away differences between browser, Node, and other environments. Key differentiator: it is the core dependency behind React Router v4, offering createHistory, createHashHistory, and createMemoryHistory. Release cadence is infrequent; v2 is stable but superseded by v4 (ESM) and v5 (React Router). Note: This version uses CommonJS; ESM was introduced in later versions.
npm install create-historyNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to create a browser history, listen for location changes, push a new entry, and use memory history in non-browser environments.
Use require() or configure bundler for CommonJS. For ESM, upgrade to v4+.
Avoid using them; they are not present in v2.1.1 final? Actually they were removed earlier. Check docs.
Use named import: import { createHistory } from 'history'.For server-side rendering, use createMemoryHistory or check if window exists.
Update listeners when upgrading to v3: (location, action) => void.
Use require('history').createHistory or configure bundler (e.g., webpack) to handle CommonJS named exports.Use createMemoryHistory() instead of createHistory() in Node.js.
Ensure you use createHistory (or createMemoryHistory) to create the history object.
Check that location is defined: const location = history.getCurrentLocation(); or wait for listener to fire.
No dependency data recorded yet.