Installation

@beforesemicolon/router works in bundled applications and directly in modern browsers through CDN script tags.

Package Managers

Install the package via your preferred package manager to bundle it with Vite, Webpack, or Esbuild:

npm

sh
1npm install @beforesemicolon/router

yarn

sh
1yarn add @beforesemicolon/router

pnpm

sh
1pnpm add @beforesemicolon/router

Direct CDN (Zero-Build)

For simple HTML prototypes or build-less applications, load the compiled browser bundles directly from unpkg.com or jsDelivr:

html
1<!-- 1. Import the base web component library (Required dependency) -->2<script src="https://unpkg.com/@beforesemicolon/web-component/dist/client.js"></script>3 4<!-- 2. Import the router browser bundle -->5<script src="https://unpkg.com/@beforesemicolon/router/dist/client.js"></script>

Locking Versions

It is highly recommended to lock the version in production environments to avoid breaking changes when new updates are published:

html
1<script src="https://unpkg.com/@beforesemicolon/router@1.2.0/dist/client.js"></script>

Global Namespace

When loaded via a script tag, all exported classes, routing functions, and utilities are available under the global BFS window object:

javascript
1// Access router components and APIs2const { goToPage, onPage, registerRouteGuard } = BFS.ROUTER
edit this doc