history

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

Library
npm
v5.3.0
8,297 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
82%
Other

AFFiNE

Collaboration · Note Taking · Productivity

73,040

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
67
Dependency
Built with
TypeScript 82%
Rust 11%
Updated 6 days ago
TypeScript
89%
Other

anytype-ts

Collaboration · Knowledge Management · Note Taking

8,861

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
TypeScript 89%
Updated 1 weeks ago
TypeScript
68%
Apache 2.0

Appsmith

Automation · Developer Tools · No Code Platforms

40,959

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

View details
93
Repo Health
79
Technical
66
Dependency
Built with
TypeScript 68%
Java 21%
Updated 1 weeks ago
Go
85%
Apache 2.0

Argo Workflows

Data Engineering · Devops

17,006

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
68
Dependency
Built with
Go 85%
TypeScript 11%
Updated 5 days ago
Go
55%
Apache 2.0

Authgear

Authentication

2,074

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
68
Dependency
Built with
Go 55%
HTML 24%
TypeScript 18%
Updated 1 weeks ago
TypeScript
97%
AGPL 3.0

Bigcapital

Invoicing Finance

3,916

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

View details
90
Repo Health
77
Technical
61
Dependency
Built with
TypeScript 97%
Updated 1 weeks ago
Java
48%
Apache 2.0

ClearFlask

Community · Product Management

451

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
62
Dependency
Built with
Java 48%
TypeScript 47%
Updated 1 weeks ago
Go
49%
Other

Cosmos-Server

Authentication · Security

6,167

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
83
Repo Health
59
Technical
64
Dependency
Built with
Go 49%
JavaScript 48%
Updated 2 weeks ago
Python
63%
BSD 3

Flagsmith

Ab Testing Experimentation · Developer Tools · Devops

6,577

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
90
Repo Health
82
Technical
63
Dependency
Built with
Python 63%
TypeScript 31%
Updated 1 weeks 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