Registry / web-framework / vhistory

vhistory

JSON →
library1.0.1jsnpmunverified

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.

npm install vhistory
INSTALL
IMPORT
SIG · VHISTORY
V
vhistory
web-frameworkjavascriptv1.0.1
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.

createHistory
import { createHistory } from 'vhistory'
import createHistory from 'vhistory'
Default import is not available; must use named import.
createHistory (CommonJS)
const { createHistory } = require('vhistory')
const createHistory = require('vhistory')
CommonJS require returns an object; destructure to get createHistory.
UMD global
const history = window.History.createHistory()
const history = window.history.createHistory()
UMD build exposes `window.History` (capital H), not `window.history`.

Demonstrates basic usage: create a history object, listen for location changes, push a new entry, and stop listening.

import { createHistory } from 'vhistory'; const history = createHistory(); const unlisten = history.listen(location => { console.log('Current location:', location.pathname); }); history.push({ pathname: '/about', search: '?from=home', state: { detail: 'example' } }); // Later, stop listening unlisten();
Debug
Known issues
gotchaThe 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.
fix
Install using `npm install --save vhistory` and import from `'vhistory'`.
affects: >=1.0.0
gotchaThe 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.
fix
Access via `window.History.createHistory()` or destructure: `const { createHistory } = window.History`.
affects: >=1.0.0
gotchaThe `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.
fix
If upgrading to modern versions, use `history` package v4+ and methods like `createBrowserHistory`.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: (0 , _vhistory.createHistory) is not a function
Using a default import instead of named import.
fix
Change `import createHistory from 'vhistory'` to `import { createHistory } from 'vhistory'`.
Cannot read property 'listen' of undefined
Calling `history.listen` before `createHistory()` returns a valid object, or using `window.history` instead of `window.History`.
fix
Ensure `const history = createHistory();` returns an object, and if using UMD, use `window.History.createHistory()`.
Module not found: Can't resolve 'vhistory'
The package is not installed or the import path is incorrect.
fix
Run `npm install --save vhistory` and ensure import path is `'vhistory'` (not `'history'`).
Upgrade
Version history
1.0.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
11 hits · last 30 days
node
10
OpenAI (training)
1
Resources
vhistory — npm install vhistory · libregistry