npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@zenithbuild/router

v1.0.3

Published

File-based SPA router for Zenith framework with deterministic, compile-time route resolution

Readme

@zenithbuild/router

File-based SPA router for Zenith framework with deterministic, compile-time route resolution.

Features

  • 📁 File-based routing — Pages in pages/ directory become routes automatically
  • Compile-time resolution — Route manifest generated at build time, not runtime
  • 🔗 ZenLink component — Declarative navigation with prefetching
  • 🧭 Programmatic navigationnavigate(), prefetch(), isActive() APIs
  • 🎯 Type-safe — Full TypeScript support with route parameter inference
  • 🚀 Hydration-safe — No runtime hacks, works seamlessly with SSR/SSG

Installation

bun add @zenithbuild/router

Usage

Programmatic Navigation

import { navigate, prefetch, isActive, getRoute } from '@zenithbuild/router'

// Navigate to a route
navigate('/about')

// Navigate with replace (no history entry)
navigate('/dashboard', { replace: true })

// Prefetch a route for faster navigation
prefetch('/blog')

// Check if a route is active
if (isActive('/blog')) {
  console.log('Currently on blog section')
}

// Get current route state
const { path, params, query } = getRoute()

ZenLink Component (in .zen files)

<ZenLink href="/about">About Us</ZenLink>

<!-- With prefetching on hover -->
<ZenLink href="/blog" preload>Blog</ZenLink>

<!-- External links automatically open in new tab -->
<ZenLink href="https://github.com">GitHub</ZenLink>

Build-time Route Manifest

The router generates a route manifest at compile time:

import { generateRouteManifest, discoverPages } from '@zenithbuild/router/manifest'

const pagesDir = './src/pages'
const manifest = generateRouteManifest(pagesDir)

// manifest contains:
// - path: Route pattern (e.g., /blog/:id)
// - regex: Compiled RegExp for matching
// - paramNames: Dynamic segment names
// - score: Priority for deterministic matching

Route Patterns

| File Path | Route Pattern | |-----------|---------------| | pages/index.zen | / | | pages/about.zen | /about | | pages/blog/index.zen | /blog | | pages/blog/[id].zen | /blog/:id | | pages/posts/[...slug].zen | /posts/*slug | | pages/[[...all]].zen | /*all? (optional) |

Architecture

@zenithbuild/router
├── src/
│   ├── index.ts          # Main exports
│   ├── types.ts          # Core types
│   ├── manifest.ts       # Build-time manifest generation
│   ├── runtime.ts        # Client-side SPA router
│   └── navigation/
│       ├── index.ts      # Navigation exports
│       ├── zen-link.ts   # Navigation API
│       └── ZenLink.zen   # Declarative component

API Reference

Navigation Functions

  • navigate(path, options?) — Navigate to a path
  • prefetch(path) — Prefetch a route for faster navigation
  • isActive(path, exact?) — Check if path is currently active
  • getRoute() — Get current route state
  • back(), forward(), go(delta) — History navigation

Manifest Generation

  • discoverPages(pagesDir) — Find all .zen files in pages directory
  • generateRouteManifest(pagesDir) — Generate complete route manifest
  • filePathToRoutePath(filePath, pagesDir) — Convert file path to route
  • routePathToRegex(routePath) — Compile route to RegExp

Types

  • RouteState — Current route state (path, params, query)
  • RouteRecord — Compiled route definition
  • NavigateOptions — Options for navigation
  • ZenLinkProps — Props for ZenLink component

License

MIT

zenith-router