Introduction

High-performance, file-based REST API router for TypeScript. Zero runtime drift, cascading middleware context, and automatic client generation.

Taser is a modern, type-safe, file-based router designed for scalable Node.js and edge HTTP services. It bridges the gap between clean filesystem architecture and strict type safety.

Traditional Node.js routing forces you to write manual route registries, perform unsafe type assertions on req.user, and maintain separate client types that drift over time. Taser solves these challenges by treating the filesystem as the source of truth, cascading middleware state through directory layouts, and generating a 100% typed client SDK.

src/routes/users/$id.get.ts
import { json, notFound } from "@taserjs/router/reply";
import { z } from "zod";
import { t } from "@taserjs/router";

const GET = t
  .get("/users/:id")
  .params(z.object({ id: z.string().uuid() }))
  .query(z.object({ includeProfile: z.coerce.boolean().default(false) }))
  .returns({
    200: z.object({ id: z.string(), name: z.string(), email: z.string() }),
    404: z.object({ message: z.string() }),
  });

export type RouteContext = typeof GET.$Infer.Context;
export default GET.handler(async (ctx) => {
  // ctx.params.id is typed as string (UUID)
  // ctx.query.includeProfile is typed as boolean
  // ctx.state contains data injected by layout middlewares
  const user = await ctx.db.findUserById(ctx.params.id);
  if (!user) {
    return notFound({ message: "User not found" });
  }

  return json(user);
});

Why Taser?

Deterministic File Routing

Drop .get.ts, .post.ts, or .put.ts files into your routes directory. Routes, parameters, and splats are discovered automatically with virtual module HMR.

Cascading Context Inference

Middleware state declared in root or folder layouts flows directly into ctx.state for child routes with zero typecasting or global namespace pollution.

Compile-Time Return Contracts

Declare response schemas with .returns(). The TypeScript compiler verifies that your handler return shapes match your published API contracts.

Standard Schema Validation

Validate query parameters, path params, headers, and request bodies using Zod, ArkType, Valibot, or any Standard Schema library.

Vite Native & Nitro Presets

Vite-native development with virtual routing and instant HMR. Deploy anywhere using Nitro multi-cloud presets, or embed inside Next.js and host apps.

Zero-Drift Typed Client

Export your router type and call your backend using an auto-completing, fully typed client that guarantees 1:1 parity with server endpoints.


How Taser Works

Taser operates around a deterministic, fully type-safe request lifecycle:

Taser Request Execution Pipeline

Click any stage to inspect lifecycle execution, data flow, and type inference

Stage 01RUNTIME

Runtime & Platform Resolution

The incoming HTTP request is received by the platform runtime and dispatched into Taser's radix tree via a Web Standard Request object.

Execution Highlights
Dispatch Mechanism: Web Standard Request / Response interface
Supported Runtimes: Vite Dev / Prod, Nitro Presets, Next.js App Router, Express, Fastify, Fetch hosts
Virtual Routing: Compiled static manifest with zero filesystem lookups at runtime
server.tsTypeScript
// Taser receives Web Standard Request
const response = await taserApp.fetch(request);
1 of 7

Vite-Powered Virtual Modules

Taser integrates with Vite via @taserjs/router-plugin/vite. Routes are loaded virtually during development with instant HMR and bundled into optimized production artifacts via Nitro deployment presets.


Scaffold with create-taserjs

Get up and running in seconds using the official scaffolding CLI. Customize your stack across five modular dimensions:

  • Host Framework: Standalone Taser (none), hono, express, or fastify.
  • Deployment Preset: node-server, node-cluster, bun, deno-server, deno-deploy, cloudflare-module, vercel, aws-lambda, netlify, or standalone Vite (none).
  • Runtime Override: Explicit node or bun execution target for self-hosted presets.
  • Database & Driver: Drizzle, Prisma, or Kysely with SQLite, PostgreSQL, or MySQL drivers (--db <odm>:<driver>).
  • Standard Add-ons: Zod, ArkType, or Valibot for schema validation; Pino or Winston for structured logging.
pnpm create taserjs@latest my-api

For full flag definitions and project structure options, see the Quickstart Guide.


Quick Navigation

Explore the documentation to start building or migrating your existing server: