{"id":26585,"library":"vhistory","title":"vhistory","description":"A JavaScript library for managing browser session history anywhere JavaScript runs. vhistory 1.0.1 is a repackaged version of the popular `history` library by ReactTraining, abstracting environment differences and providing a minimal API to manage the history stack, navigate, confirm navigation, and persist state between sessions. It supports ES6 import and CommonJS require, with a UMD build available on unpkg. Key differentiators: simple API with `createHistory`, `push`, `replace`, `listen`, `goBack`, and `goForward` methods; compatible with browser and server-side environments.","status":"active","version":"1.0.1","language":"javascript","source_language":"en","source_url":"https://github.com/vifird/history","tags":["javascript","history","location"],"install":[{"cmd":"npm install vhistory","lang":"bash","label":"npm"},{"cmd":"yarn add vhistory","lang":"bash","label":"yarn"},{"cmd":"pnpm add vhistory","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Default import is not available; must use named import.","wrong":"import createHistory from 'vhistory'","symbol":"createHistory","correct":"import { createHistory } from 'vhistory'"},{"note":"CommonJS require returns an object; destructure to get createHistory.","wrong":"const createHistory = require('vhistory')","symbol":"createHistory (CommonJS)","correct":"const { createHistory } = require('vhistory')"},{"note":"UMD build exposes `window.History` (capital H), not `window.history`.","wrong":"const history = window.history.createHistory()","symbol":"UMD global","correct":"const history = window.History.createHistory()"}],"quickstart":{"code":"import { createHistory } from 'vhistory';\n\nconst history = createHistory();\n\nconst unlisten = history.listen(location => {\n  console.log('Current location:', location.pathname);\n});\n\nhistory.push({\n  pathname: '/about',\n  search: '?from=home',\n  state: { detail: 'example' }\n});\n\n// Later, stop listening\nunlisten();","lang":"javascript","description":"Demonstrates basic usage: create a history object, listen for location changes, push a new entry, and stop listening."},"warnings":[{"fix":"Install using `npm install --save vhistory` and import from `'vhistory'`.","message":"The package is named `vhistory` on npm but the GitHub repository and documentation refer to `history`. Ensure you install `vhistory`, not `history`, as `history` is a different package.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Access via `window.History.createHistory()` or destructure: `const { createHistory } = window.History`.","message":"The UMD bundle expects `window.History` (capital H) as the global variable. Using `window.history` will refer to the native browser History API, not the library.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"If upgrading to modern versions, use `history` package v4+ and methods like `createBrowserHistory`.","message":"The `history` package v1.x (and thus vhistory) is a legacy API. The newer v3/v4 versions of the original `history` package have a different API (e.g., `createBrowserHistory`). vhistory reflects the older API for compatibility.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'1.0.1':14 'abstract':26 'anywher':10 'api':33,64 'avail':58 'browser':7,76 'build':57 'commonj':52 'compat':74 'confirm':40 'createhistori':66 'differ':28 'differenti':62 'environ':27,81 'es6':49 'goback':70 'goforward':72 'histori':9,22,37,83 'import':50 'javascript':3,11,82 'key':61 'librari':4,23 'listen':69 'locat':84 'manag':6,35 'method':73 'minim':32 'navig':39,41 'persist':43 'popular':21 'provid':30 'push':67 'reacttrain':25 'repackag':17 'replac':68 'requir':53 'run':12 'server':79 'server-sid':78 'session':8,46 'side':80 'simpl':63 'stack':38 'state':44 'support':48 'umd':56 'unpkg':60 'version':18 'vhistori':1,13","created_at":"2026-05-01T13:50:44.473221+00:00","updated_at":"2026-05-01T13:50:44.473221+00:00","problems":[{"fix":"Change `import createHistory from 'vhistory'` to `import { createHistory } from 'vhistory'`.","cause":"Using a default import instead of named import.","error":"TypeError: (0 , _vhistory.createHistory) is not a function"},{"fix":"Ensure `const history = createHistory();` returns an object, and if using UMD, use `window.History.createHistory()`.","cause":"Calling `history.listen` before `createHistory()` returns a valid object, or using `window.history` instead of `window.History`.","error":"Cannot read property 'listen' of undefined"},{"fix":"Run `npm install --save vhistory` and ensure import path is `'vhistory'` (not `'history'`).","cause":"The package is not installed or the import path is incorrect.","error":"Module not found: Can't resolve 'vhistory'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/vifird/history","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/vhistory","openapi_spec":null,"status_page":null,"smithery":null,"categories":["web-framework","http-networking"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-05-01","next_check":"2026-07-30","install_tag":null}}