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

orbit-router

v1.0.1

Published

Directory-based, type-safe router for Vite+ and React.

Readme

Orbit Router

Directory-based React router built on Vite. Drop files into routes/ and get type-safe routing with zero configuration.

Part of the Orbit frontend toolkit — designed so that AI-generated code and human-written code always look the same.

Features

  • File-based routingroutes/page.tsx/, routes/about/page.tsx/about
  • Dynamic routesroutes/users/[id]/page.tsx/users/:id
  • Nested layoutslayout.tsx at any level wraps child routes
  • Guardsguard.ts for route-level access control (auth checks, redirects)
  • Error boundarieserror.tsx per route with automatic bubbling
  • Loading statesloading.tsx per route
  • 404 pagesnot-found.tsx for custom 404 handling
  • Code splitting — Page components are lazy-loaded with React.lazy
  • Type-safe paramsuseParams<"/users/:id">() returns { id: string }
  • Type-safe links<Link href="/typo"> is a type error
  • Type-safe search paramsuseSearchParams(parse) with optional validation
  • Navigation stateuseNavigation() for progress indicators
  • SSR-ready<Router url={request.url}> for server-side rendering

Quick Start

pnpm add orbit-router
// vite.config.ts
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import { orbitRouter } from "orbit-router";

export default defineConfig({
  plugins: [react(), orbitRouter()],
});
// src/app.tsx(orbit-ssr-plugin を使う場合は自動生成されるため不要)
import { routes, NotFound } from "virtual:orbit-router/routes";
import { Router } from "orbit-router";

export function App() {
  return <Router routes={routes} NotFound={NotFound} />;
}

File Conventions

src/routes/
  page.tsx          → /
  layout.tsx        → Root layout (wraps all pages)
  not-found.tsx     → Custom 404 page
  about/
    page.tsx        → /about
  users/
    page.tsx        → /users
    server.ts       → Data access (RPC-style functions)
    hooks.ts        → React hooks (useQuery wrappers)
    schema.ts       → Zod schemas + types
    guard.ts        → Access control
    loading.tsx     → Loading state
    error.tsx       → Error boundary
    [id]/
      page.tsx      → /users/:id

| File | Purpose | | --------------- | ----------------------------------------------------------------------------- | | page.tsx | Page component (required for a route to exist) | | layout.tsx | Wraps child routes with {children} prop. Can also export a guard function | | guard.ts | Separate guard file (optional, takes priority over layout export) | | loading.tsx | Shown during initial page load | | error.tsx | Error boundary. Bubbles up to nearest parent if not present | | not-found.tsx | Custom 404 page (root level) |

API

Hooks

import { useParams, useSearchParams, useNavigation, useNavigate } from "orbit-router";

// Type-safe params
const { id } = useParams<"/users/:id">();

// Search params with optional parsing
const [search, setSearch] = useSearchParams((raw) => ({
  page: Number(raw.page ?? 1),
  q: raw.q ?? "",
}));
setSearch({ page: 2 }); // merge into URL
setSearch({ q: null }); // remove param

// Navigation state
const { state } = useNavigation(); // "idle" | "loading"

// Programmatic navigation
const navigate = useNavigate();
navigate("/users/1");
navigate(-1); // history.back()

Components

import { Link } from "orbit-router";

<Link href="/about">About</Link>;

Guards

Guards can be exported from layout.tsx (default) or placed in a separate guard.ts file:

// routes/admin/layout.tsx — guard lives with the layout (recommended for short guards)
import type { GuardArgs } from "orbit-router";
import { redirect } from "orbit-router";

export async function guard({ signal }: GuardArgs) {
  const session = await getSession({ signal });
  if (!session) redirect("/login");
  return true;
}

export default function AdminLayout({ children }: { children: React.ReactNode }) {
  return <div>{children}</div>;
}

For complex guards, extract to a separate file:

// routes/admin/guard.ts — takes priority over layout export
import type { GuardArgs } from "orbit-router";
import { redirect } from "orbit-router";

export default async function guard({ signal }: GuardArgs) {
  // complex auth logic...
}

SSR Support

The <Router> component accepts a url prop for server-side rendering. When provided, the router uses this URL instead of window.location:

// Server-side
<Router routes={routes} url={request.url} />

// Client-side (default — uses window.location)
<Router routes={routes} />

When url is set:

  • window.location is never accessed (safe in non-browser environments)
  • Navigation and guards are disabled (server renders a static snapshot)
  • If url is omitted in an environment without window, the router throws an error

This is an additive change — existing CSR code works without modification.

Type Safety

Route types are auto-generated when the dev server starts. Add .orbit to your tsconfig.json:

{
  "include": ["src", ".orbit"]
}
// Typed params — typos become type errors
const { id } = useParams<"/users/:id">()

// Typed links — only valid routes accepted
<Link href="/users/123">Profile</Link>  // ✓
<Link href="/typo">Oops</Link>          // ✗ type error

License

MIT