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.
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.
Links