Getting Started

Quickstart

Create and run a new TaserJS project in under a minute with create-taserjs. Choose your favorite server adapter, schema validator, ORM, and logger.

The quickest way to get started with Taser is using the official create-taserjs scaffolding tool. It generates a pre-configured, production-ready project with TypeScript, hot-reloading, route watching, and your choice of tools.


Prerequisites

Before creating a project, make sure your development environment meets these requirements:

  • Node.js: Version 20.19.0 or higher
  • Package Manager: npm, pnpm, yarn, or bun
  • TypeScript: Version 5.0 or higher

Create a New Project

Run the Scaffolding Command

Run the interactive initializer in your terminal:

pnpm create taserjs@latest

Choose Your Stack

The interactive wizard will guide you through selecting your preferred tools:

  1. Project Name: Enter a directory name (for example, my-taser-api).
  2. Host Framework:
    • None (Standalone): Pure Taser with high-performance virtual routing and zero host overhead (default).
    • Hono: Lightweight web standard framework for Node, Bun, Deno, and edge runtimes.
    • Express: Battle-tested Node.js web framework with pass-through routing.
    • Fastify: High-throughput Node.js framework with pass-through routing.
  3. Deployment Target / Preset:
    • Node Server (node-server, node-cluster): Standard Node.js environments (default: node-server).
    • Standalone Vite (none): Direct vite build with production serve shim without Nitro.
    • Serverless & Edge: cloudflare-module, vercel, aws-lambda, netlify.
    • Runtimes: bun, deno-server, deno-deploy.
  4. Runtime Override (Optional):
    • Override runtime for self-hosted targets (node, bun, or preset default).
  5. Database / ORM (Optional):
    • Drizzle, Prisma, Kysely, or None (supports sqlite, postgres, or mysql drivers).
  6. Logger (Optional):
    • Pino, Winston, or standard Console.
  7. Schema Validator (Optional):
    • Zod: TypeScript-first schema declaration and validation.
    • ArkType: TypeScript-native syntax with runtime performance.
    • Valibot: Modular, lightweight, tree-shakeable schema library.

Non-Interactive Scaffolding

You can pass CLI flags directly for automated or CI environments:

pnpm create taserjs@latest my-api \
  --framework none \
  --preset node-server \
  --db drizzle:postgres \
  --validator zod \
  --logger pino \
  -y

CLI Flags Reference

FlagDescriptionValues / SyntaxDefault
--frameworkHost server frameworknone, hono, express, fastifynone
--preset, -pDeployment preset (Nitro target or none)none, node-server, node-cluster, bun, deno-server, deno-deploy, cloudflare-module, vercel, aws-lambda, netlifynode-server
--runtimeExplicit runtime override (for self-hosted presets)node, bun, denoImplied by preset
--dbDatabase ODM and optional driver (odm:driver)drizzle, prisma, kysely with :sqlite, :postgres, :mysql (e.g. drizzle:postgres)None (driver defaults to sqlite)
--validatorSchema validation libraryzod, arktype, valibotNone
--loggerStructured logger integrationpino, winstonNone
-y, --yesNon-interactive mode using defaults for omitted flagsbooleanfalse
--noInstallSkip automatic package installationbooleanfalse
--jsonOutput result as JSON (prints capability catalog when no name)booleanfalse

Start the Development Server

Navigate to your new project directory, install dependencies, and start the development server:

cd my-taser-api
pnpm install
pnpm dev

The development server starts with Vite. Route changes inside src/routes/ are updated virtually with instant HMR and ambient TypeScript definitions written to .taser/types/.


Project Structure Overview

A freshly scaffolded Taser project contains a clean, modern layout:

package.json
tsconfig.json
vite.config.ts
taser.ts
context.ts
$.ts
/*
index.get.ts
/
health.get.ts
/health

Key Files Explained

  • vite.config.ts: Connects the taser() plugin from @taserjs/router-plugin/vite and nitro() for zero-config builds (or pure Vite in standalone none preset).
  • nitro.config.ts (conditional): Generated when targeting non-default deployment presets (e.g. cloudflare-module, vercel, aws-lambda, netlify). Omitted for default node-server and standalone none.
  • src/server.ts / src/server.node.ts (conditional): Generated when a host framework is configured (src/server.ts for Hono, src/server.node.ts for Express or Fastify).
  • src/taser.ts: Configures the createTaserApp() instance, error boundaries (.onError()), response validation, and context binding.
  • src/context.ts: Defines application singletons (database, logger, external services) and request-scoped context.
  • src/routes/: Contains your API endpoints (index.get.ts, health.get.ts) and root layout middleware ($.ts).
  • .taser/: Contains auto-generated ambient TypeScript types (.taser/types/) so your editor provides full route autocomplete.

Add Your First Route

To create a new endpoint, add a file in the src/routes/ directory.

Create src/routes/hello.get.ts:

src/routes/hello.get.ts
import { json } from "@taserjs/router/reply";
import { t } from "@taserjs/router";

export default t.get("/hello").handler(() => {
  return json({
    message: "Hello from Taser!",
    timestamp: new Date().toISOString(),
  });
});

Save the file. Vite hot-reloads the new route immediately without restarting the dev server.

Test your new endpoint in another terminal or browser:

curl http://localhost:3000/hello

Response:

{
  "message": "Hello from Taser!",
  "timestamp": "2026-08-25T00:00:00.000Z"
}

Automatic Boilerplate Generation

When you create a new empty route file (e.g. touch src/routes/users/$id.get.ts), Vite or npx taser generate automatically fills it with type-safe starter boilerplate.


Next Steps

Now that your project is running, explore these guides to build out your application: