All projects

Developer Tool / Library

History++

A lightweight, UI-agnostic navigation engine built on top of the native History API. Extends window.history with structured routing, direction-aware lifecycle hooks, and navigation orchestration.

  • TypeScript
  • JavaScript
  • History API
  • SPA
History++ interface
History++ — UI-agnostic navigation engine with direction-aware lifecycle hooks.

Overview

Predictable route lifecycles without taking over rendering.

History++ adds predictable route lifecycles to the native History API without taking over rendering. It preserves browser back/forward behavior while enabling direction-aware hooks.

Designed for developers who need route matching and lifecycle control without adopting unnecessary framework features.

The problem

Heavy routers couple navigation with rendering unnecessarily.

Most SPAs use heavy routers that couple navigation with rendering. Developers who only need route matching and lifecycle control must adopt unnecessary framework features.

  • Existing routers force framework adoption for simple navigation needs.
  • No direction-aware lifecycle hooks in native History API.
  • Developers need middleware and guards without full routing frameworks.

Approach

Orchestration layer with direction-aware lifecycle hooks.

Designed as an orchestration layer only. Introduces direction-aware lifecycle hooks (onArrive, onExit, onReturn, onComeback) that change behavior based on navigation direction.

The approach focuses on doing one thing well: managing navigation state and lifecycle without dictating how rendering happens.

Solution

Lightweight matcher with trie-based and regex strategies.

Built a lightweight matcher with trie-based and regex strategies. Supports history and hash modes, middleware, guards (canLeave), and wildcard fallback. Zero dependencies.

The library is framework-agnostic and can be used with any rendering approach, from vanilla JS to React, Vue, or Svelte.

History++ architecture diagram
Direction-aware lifecycle hooks and middleware pipeline.

Implementation

Technical implementation.

Built with TypeScript using native ESM, the library provides trie-based route matching with fallback to regex for complex patterns.

Core

TypeScript, native ESM, trie-based route matching with regex fallback.

Features

Direction-aware lifecycle, middleware pipeline, guards (canLeave), wildcard fallback.

Testing

Node.js test runner for comprehensive specs and examples.

Results

What changed.

The library provides a complete navigation solution with comprehensive examples and documentation.

14interactive examples and demos
0runtime dependencies
Fulldocs at historypp.digital

Links

Let's work together

Have a problem worth solving?

Let's talk about your project, technical challenge, or next idea.

Get in touch