history

Manage session history and navigation state across browser, hash, and in-memory environments in JavaScript.

Library
npm
v5.3.0
8,294 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
50 /100 Fair
Development Activity 0
Maintenance 20
Community 80
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
80 /100 Excellent
Architecture 80
Code Quality 80
Innovation 85
Learning Curve 85

history is a small, dependency-light JavaScript library that abstracts the differences between browser navigation environments behind a single, consistent API. It provides three interchangeable history implementations — browser history (backed by the HTML5 History API), hash history (for servers you don’t control), and memory history (for tests and React Native) — so the same push/replace/go/listen calls work identically regardless of where the app runs.

Most developers encounter history indirectly: it is the navigation engine underneath React Router, handling the actual pushState/replaceState/popstate plumbing so routing libraries can focus on matching and rendering. It exposes typed Location, Action, and Update primitives plus createPath/parsePath helpers for working with URL segments directly.

What You Get

  • createBrowserHistory for standard HTML5 pushState/replaceState-based routing in web browsers
  • createHashHistory for storing location in the URL fragment when the server can’t be configured for client-side routing
  • createMemoryHistory for stateful non-browser environments such as tests and React Native, with a readable stack index
  • A shared History interface (action, location, push, replace, go, back, forward, listen, block, createHref) so app code is portable across environments
  • createPath and parsePath utilities for converting between string URLs and {pathname, search, hash} objects
  • Navigation blocking via history.block() to prompt users before leaving a page with unsaved changes

Common Use Cases

  • Powering client-side routing under React Router or a custom router that needs a normalized navigation API
  • Building a single-page app that must support both standard browser URLs and hash-based routing for static hosting
  • Driving navigation in React Native or other non-DOM environments via createMemoryHistory
  • Implementing ‘unsaved changes’ confirmation prompts before allowing navigation away from a form
  • Writing router or navigation-aware component tests against a controllable in-memory history stack

Under The Hood

Architecture — index.ts implements three factory functions (createBrowserHistory, createHashHistory, createMemoryHistory) that share one internal pattern: each closure maintains a mutable action/location pair, an event bus (createEvents) for listeners and blockers, and helpers (getIndexAndLocation, getNextLocation, applyTx) that keep the tracked state in sync with the underlying source of truth. Browser and hash histories wrap the native window.history object (pushState/replaceState and the popstate/hashchange events); memory history instead keeps an in-memory array of Location entries with an index pointer. All three satisfy the same History interface, which is what lets React Router and other consumers swap environments without changing call sites.

Tech Stack — Written entirely in TypeScript and compiled with Rollup (rollup-plugin-typescript2) into CJS, ESM, and UMD bundles; Babel with babel-plugin-dev-expression strips dev-only warning code from production builds. The package has zero runtime dependencies besides @babel/runtime helpers, and the repo is an npm workspace with a single publishable package (packages/history). Tests run through Karma + Mocha across real browsers via BrowserStack, plus a Node-based runner for memory history.

Code Quality — The tests directory contains dedicated suites for browser, hash, and memory histories, along with shared TestSequences fixtures that are run against all three implementations to guarantee consistent behavior. Every exported type and function carries JSDoc comments linking back to the docs site, and a small warning() helper surfaces dev-time console warnings (e.g. for relative pathnames or navigation to unrecognized locations) instead of failing silently. Strict TypeScript typing is used throughout with no any leakage in the public surface.

API Design — A single History interface (action, location, push, replace, go, back, forward, listen, block, createHref) is shared across all three environments, so there is exactly one API to learn regardless of target platform. The surface area is intentionally small — a handful of factory functions plus createPath/parsePath — and is backed by a docs/ directory covering getting-started, installation, navigation, and blocking-transitions guides in addition to inline JSDoc, giving new users a fast path to productivity even though the project itself has been in maintenance mode since 2022.

Used by 28 apps in this directory

TypeScript
62%
Other

Flowise

AI Development · Automation · Developer Tools

55,521

Drag-and-drop visual builder for AI agents, RAG pipelines, and multi-agent systems—deploy anywhere in minutes.

View details
75
Repo Health
77
Technical
63
Dependency
Built with
TypeScript 62%
JavaScript 27%
Updated 2 months ago
TypeScript
47%
AGPL 3.0

Grafana

Analytics · Monitoring

77,469

The open-source observability platform that unifies metrics, logs, and traces from any data source into dynamic, queryable dashboards.

View details
95
Repo Health
91
Technical
63
Dependency
Built with
TypeScript 47%
Go 47%
Updated 5 days ago
TypeScript
98%
Other

Kibana

Analytics · Monitoring

21,338

Your open source window into the Elastic Stack — query, visualize, and act on data stored in Elasticsearch with real-time dashboards, AI-assisted search, and automated alerting.

View details
98
Repo Health
87
Technical
63
Dependency
Built with
TypeScript 98%
Updated 5 days ago
TypeScript
39%
Apache 2.0

Label Studio

AI Development · Data Engineering

28,540

Label Studio is an open-source, multi-type data labeling platform that lets teams annotate images, text, audio, video, and time series data with a configurable XML-based UI and export annotations in formats ready for any ML framework.

View details
93
Repo Health
87
Technical
64
Dependency
Built with
TypeScript 39%
JavaScript 27%
Python 25%
Updated 6 days ago
Python
55%
MIT

LibrePhotos

File Storage

8,111

Self-hosted photo library with AI-powered face recognition, semantic search, and automatic event albums — no cloud required.

View details
84
Repo Health
78
Technical
66
Dependency
Built with
Python 55%
TypeScript 43%
Updated 5 days ago
TypeScript
44%
Other

Magic

AI Agents · Automation · Low Code Platforms

5,055

Magic is an enterprise-grade open-source AI agent platform combining a generalist AI agent, workflow engine, IM, and collaborative office system for running an AI-powered digital workforce.

View details
68
Repo Health
79
Technical
65
Dependency
Built with
TypeScript 44%
PHP 32%
Updated 2 months ago
Ruby
59%
AGPL 3.0

Mastodon

Social Media

50,441

Run your own federated social network on the open ActivityPub standard with no ads, no algorithms, and no corporate control over your community.

View details
95
Repo Health
81
Technical
70
Dependency
Built with
Ruby 59%
TypeScript 24%
Updated 5 days ago
TypeScript
51%
Other

Mattermost

Collaboration · Devops · Team Chat

39,418

Open core, self-hosted team collaboration with chat, AI agents, voice calling, and deep DevOps integrations — all under your control.

View details
96
Repo Health
87
Technical
65
Dependency
Built with
TypeScript 51%
Go 40%
Updated 5 days ago
Clojure
57%
Other

Metabase

Analytics

49,827

The open-source BI platform that lets anyone ask questions and build dashboards without writing SQL — with an embedded analytics SDK and AI-powered query assistant included.

View details
95
Repo Health
84
Technical
62
Dependency
Built with
Clojure 57%
TypeScript 38%
Updated 5 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers