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

siroute

v1.0.1

Published

Universal schema-driven routing engine with build-time AOT compilation. Framework-agnostic routing for React, Next.js, Expo, and React Native CLI.

Downloads

261

Readme

Siroute — Universal Schema-Driven Routing Engine

Zero-boilerplate, framework-agnostic routing with build-time AOT compilation.

Siroute decouples your application views from underlying framework routers. Define your routes once in a JSON schema, and siroute generates the wiring for React Router, Next.js App Router, Expo Router, and React Native CLI (React Navigation).


Quick Start

1. Install

npm install siroute

2. Create routes-schema.json

[
  {
    "path": "/",
    "filePath": "./src/views/Home",
    "componentKey": "Home"
  },
  {
    "path": "/user/:id",
    "filePath": "./src/views/UserProfile",
    "componentKey": "UserProfile"
  },
  {
    "path": "/admin",
    "filePath": "./src/views/AdminPanel",
    "componentKey": "AdminPanel",
    "requireAuth": true,
    "allowedRoles": ["admin", "superadmin"]
  },
  {
    "path": "*",
    "filePath": "./src/views/NotFound",
    "componentKey": "NotFound"
  }
]

3. Compile

npx siroute

This generates .siroute/registry.js — a static import map with zero dynamic strings.

4. Wire Your Framework

React SPA (React Router v6/v7)

import { createSirouRouter } from "siroute/react";
import { RouterProvider } from "react-router-dom";
import { componentRegistry, routeManifest } from "./.siroute/registry";
import { UniversalAuthProvider } from "siroute/auth";

const router = createSirouRouter(componentRegistry, routeManifest);

function App() {
  return (
    <UniversalAuthProvider initialState={{ isAuthenticated: false, role: null }}>
      <RouterProvider router={router} />
    </UniversalAuthProvider>
  );
}

Next.js App Router

// app/[[...slug]]/page.tsx
import { createNextEngine } from "siroute/next";
import { componentRegistry, routeManifest } from "../../.siroute/registry";

const SirouPage = createNextEngine(componentRegistry, routeManifest);
export default SirouPage;

Expo Router

The compiler auto-generates pass-through files in app/:

npx siroute  # Generates app/*.generated.tsx

Add to .gitignore:

app/*.generated.tsx

React Native CLI (React Navigation)

import { NavigationContainer } from "@react-navigation/native";
import { createSirouNativeStack, createSirouLinkingConfig } from "siroute/native-cli";
import { componentRegistry, routeManifest } from "./.siroute/registry";
import { UniversalAuthProvider } from "siroute/auth";

const AppNavigator = createSirouNativeStack(componentRegistry, routeManifest);
const linking = createSirouLinkingConfig(routeManifest, "myapp");

function App() {
  return (
    <UniversalAuthProvider initialState={{ isAuthenticated: false, role: null }}>
      <NavigationContainer linking={linking}>
        <AppNavigator />
      </NavigationContainer>
    </UniversalAuthProvider>
  );
}

Universal Primitives

useUniversalNavigate()

import { useUniversalNavigate } from "siroute/components";

function MyComponent() {
  const nav = useUniversalNavigate();
  return <button onClick={() => nav.to("/user/42")}>View Profile</button>;
}

Auto-detects the runtime and delegates to:

  • Next.js → useRouter().push()
  • React Router → useNavigate()
  • Expo Router → router.push()
  • React Navigation → navigation.navigate()

<UniversalLink>

import { UniversalLink } from "siroute/components";

function Nav() {
  return (
    <UniversalLink href="/about" className="nav-link">
      About Us
    </UniversalLink>
  );
}
  • Web: Renders <a> tag for SEO crawlability and native link context menus
  • Native: Renders <TouchableOpacity> with navigation

Authentication & Authorization

Auth Provider

import { UniversalAuthProvider, useAuth } from "siroute/auth";

// Wrap your app
<UniversalAuthProvider initialState={{ isAuthenticated: true, role: "admin" }}>
  <App />
</UniversalAuthProvider>

// Consume anywhere
function Profile() {
  const { isAuthenticated, role, setAuthState } = useAuth();
  // ...
}

Security Guard

Routes with requireAuth: true are automatically protected. The SecurityGuard:

  1. Unauthenticated access → Renders null, redirects to /login
  2. Wrong role → Renders null, redirects to /
  3. Authorized → Renders the component

No layout flashing — view construction is killed before any child mounts.


Security

  • Prototype Pollution Protection: All query/param parsing uses Object.create(null) and blocks __proto__, constructor, prototype keys
  • No eval() or new Function(): Component lookup uses strict object literal maps only
  • Input Sanitization: Null bytes, control characters, and code injection patterns are stripped
  • Frozen Outputs: All params and query objects are Object.freeze()'d

CLI Reference

npx siroute [options]

Options:
  -s, --schema <path>    Schema file path (default: routes-schema.json)
  -r, --root <path>      Project root (default: cwd)
  -o, --output <path>    Output directory (default: .siroute)
  -c, --clean            Clean previous output before compiling
  -v, --verbose          Enable detailed logging
  -h, --help             Show help

View Component Contract

All routed components receive a standardized params prop:

import type { RouteComponentProps } from "siroute";

function UserProfile({ params }: RouteComponentProps) {
  return <h1>User ID: {params.id}</h1>;
}

export default UserProfile;

Architecture

routes-schema.json → CLI Compiler (AOT) → .siroute/registry.js
                                        → app/*.generated.tsx (Expo)

Runtime:
  registry.js → [Adapter] → [SecurityGuard] → [Your Component]
                  ↑
           React / Next / Expo / Native CLI

License

MIT