LIGHTWEIGHT SPA ROUTER

History++

A browser-native navigation engine for lifecycle routing, route guards, middleware, dynamic params, and predictable back-button behavior without owning your rendering layer.

Philosophy

History++ keeps browser-native navigation behavior intact while adding predictable route lifecycle orchestration.

The URL stays the source of truth. Routes describe UI state. Your application keeps control of rendering.

Native History First

Push, replace, and pop navigation stay close to the browser's own history stack.

Lifecycle Routing

Routes can react through onArrive, onMeet, onReturn, onExit, and onComeback hooks.

UI Agnostic

Render pages, modals, sheets, fragments, or app state with your own UI code.

Basic Usage Snapshot

Register routes, attach lifecycle handlers, then sync the current browser URL into the router on first load.

Route registration and initial URL sync

history.router("/", {
  onMeet() {
    console.log("Home");
  }
});

history.router("/about", {
  onMeet() {
    console.log("About");
  }
});

history.navigateReplace(location.pathname + location.search);

Runtime Architecture

History++ is designed around native URL state and lifecycle-aware route execution.

History++ routing architecture overview

Runtime Semantics

History++ explains navigation through route matching, context creation, guard checks, and lifecycle execution.

Route Context

Matched routes receive params, query data, navigation type, and user-provided state.

Guarded Transitions

canLeave can block unsafe movement and restore URLs during blocked pop navigation.

Middleware Pipeline

Registered middleware runs before route guards and lifecycle handlers.

Examples

Each example isolates one navigation idea so behavior is easy to inspect.

Experimental Navigation Proposal

History++ explores the idea that native browser navigation can become a richer runtime layer when route lifecycle, guards, middleware, and matching are kept small and explicit.