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

rouzer

v6.0.0

Published

Rouzer is a small TypeScript HTTP framework for projects that can share one route tree between server and client code. The route tree defines URL patterns, named actions, request validation, and response contracts once, then Rouzer uses it to build a fetc

Readme

Rouzer

Rouzer is a small TypeScript HTTP framework for projects that can share one route tree between server and client code. The route tree defines URL patterns, named actions, request validation, and response contracts once, then Rouzer uses it to build a fetch-compatible router and a typed fetch client.

Rouzer also includes a chainable middleware layer for request-scoped state, host/runtime data, background work, response callbacks, and adapter helpers that turn a router into a Fetch API handler.

Use It When

Use Rouzer when:

  • your server and client can import the same TypeScript route module
  • you want Zod validation before client requests and before server handlers
  • a fetch-compatible handler fits your runtime or adapter
  • named resource/action calls are a better fit than generated SDK classes

Consider another tool when you need OpenAPI-first schemas, generated clients for other languages, server-side response validation for every handler return, or a framework that owns rendering, deployment, and data loading.

Install

pnpm add rouzer zod

Rouzer requires ESM, Zod v4 or newer, a Fetch API implementation for clients, and a fetch-compatible server or adapter for routers.

import {
  $error,
  $type,
  chain,
  createClient,
  createRouter,
  metadata,
  toFetchHandler,
} from 'rouzer'
import * as http from 'rouzer/http'
import * as ndjson from 'rouzer/ndjson'

chain, toFetchHandler, request context types, and related middleware helpers are part of the root Rouzer API.

Small Example

import * as z from 'zod'
import {
  $type,
  chain,
  createClient,
  createRouter,
  toFetchHandler,
} from 'rouzer'
import * as http from 'rouzer/http'

type Profile = {
  id: string
  name: string
  requestId: string
}

export const profiles = http.resource('profiles/:id', {
  get: http.get({
    query: z.object({
      includePosts: z.optional(z.boolean()),
    }),
    response: $type<Profile>(),
  }),
})

export const routes = { profiles }

const requestInfo = chain().use(ctx => ({
  requestId: ctx.request.headers.get('x-request-id') ?? 'local',
}))

const router = createRouter({ basePath: 'api/' })
  .use(requestInfo)
  .use(routes, {
    profiles: {
      get(ctx) {
        return {
          id: ctx.path.id,
          name: 'Ada',
          requestId: ctx.requestId,
        }
      },
    },
  })

const fetchHandler = toFetchHandler(router)

const client = createClient({
  baseURL: 'https://example.com/api/',
  routes,
})

const profile = await client.profiles.get(
  { id: '42', includePosts: false },
  { headers: { 'x-request-id': 'docs' } }
)

The shared routes object drives the handler map and the generated client. The middleware output becomes part of the handler context, while the route schema adds typed ctx.path, ctx.query, ctx.body, and ctx.headers values.

Core Concepts

Route contracts live in shared TypeScript modules. Use rouzer/http resources for path-scoped namespaces and actions such as http.get, http.post, and http.patch for concrete HTTP operations.

Routers are chainable request handlers. createRouter() returns a handler; .use(middleware) appends middleware and .use(routes, handlers) attaches a route tree.

Handlers mirror the route tree. Rouzer validates the matched request before the handler runs, then lets the handler return JSON data, a custom Response, declared status helpers, or a response-plugin value such as an NDJSON stream.

Clients mirror the same route tree. createClient({ baseURL, routes }) returns typed action functions with flat route input objects and optional per-request RequestInit options.

Response markers are type contracts. $type<T>(), $error<T>(), and ndjson.$type<T>() shape handler and client types, but they do not re-validate handler return values at the server boundary.

Documentation

Runnable examples:

Published declarations provide exact signatures for every public export, including the rouzer/http and rouzer/ndjson subpaths. Public TSDoc in src/ owns symbol-level behavior and option details.