history

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

Library
npm
v5.3.0
8,302stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
50/100Fair
Development Activity0
Maintenance20
Community80
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
80/100Excellent
Architecture80
Code Quality80
Innovation85
Learning Curve85

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 27 apps in this directory

TypeScript
88%
Other

AFFiNE

Productivity · Project Management · Note Taking

71,668

Write, draw, and plan in one infinite canvas — the open-source alternative to Notion and Miro that keeps your data yours.

View details
91
Repo Health
87
Technical
68
Dependency
Built with
TypeScript88%
Updated today
TypeScript
89%
Other

anytype-ts

Knowledge Management · Note Taking · Collaboration

8,665

A local-first, end-to-end encrypted knowledge OS that lets you build notes, tasks, wikis, and entire apps — with your data stored offline and synced peer-to-peer.

View details
88
Repo Health
78
Technical
67
Dependency
Built with
TypeScript89%
Updated yesterday
TypeScript
66%
Apache 2.0

Appsmith

Developer Tools · Automation · No Code Platforms

40,707

Open-source low-code platform to build admin panels, dashboards, and internal tools connected to any database or API.

View details
94
Repo Health
79
Technical
68
Dependency
Built with
TypeScript66%
Java22%
Updated today
Go
85%
Apache 2.0

Argo Workflows

Devops · Data Engineering

16,916

The most popular Kubernetes-native workflow engine for orchestrating containerized DAGs, ML pipelines, CI/CD, and parallel batch jobs at scale.

View details
96
Repo Health
90
Technical
70
Dependency
Built with
Go85%
TypeScript11%
Updated today
Go
55%
Apache 2.0

Authgear

Authentication

1,989

Open-source, self-hostable authentication platform with passkeys, biometric login, SSO, MFA, and GraphQL admin API — a full Auth0/Clerk/Firebase alternative for SaaS and mobile apps.

View details
88
Repo Health
81
Technical
72
Dependency
Built with
Go55%
HTML26%
TypeScript17%
Updated yesterday
TypeScript
97%
AGPL 3.0

Bigcapital

Invoicing Finance

3,846

Self-hostable double-entry accounting platform with invoicing, inventory, multi-currency, and real-time financial reporting for small and medium businesses.

View details
91
Repo Health
77
Technical
64
Dependency
Built with
TypeScript97%
Updated yesterday
Java
48%
Apache 2.0

ClearFlask

Product Management · Community

448

Open-source feedback management and roadmap tool that lets product teams collect, prioritize, and respond to user input — with AI-powered summarization and full self-hosting control.

View details
83
Repo Health
73
Technical
63
Dependency
Built with
Java48%
TypeScript47%
Updated 2 weeks ago
JavaScript
53%
Other

Cosmos-Server

Security · Authentication

6,121

All-in-one self-hosted home server with SmartShield anti-DDoS, Nebula mesh VPN, automatic HTTPS, and a 250-app marketplace — all secured behind a unified auth layer.

View details
79
Repo Health
59
Technical
66
Dependency
Built with
JavaScript53%
Go43%
Updated yesterday
Python
64%
BSD 3

Flagsmith

Developer Tools · Devops · Ab Testing Experimentation

6,518

Open-source feature flagging, remote config, and A/B/multivariate testing platform for web, mobile, and server-side apps — self-host or use the hosted SaaS.

View details
91
Repo Health
82
Technical
65
Dependency
Built with
Python64%
TypeScript31%
Updated today

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

Search