Vite Plugin
Integrate Taser with Vite using @taserjs/router-plugin/vite. Virtual route resolution, ambient type generation, instant HMR, and standalone builds.
The @taserjs/router-plugin/vite package connects Taser's file routing engine to Vite. It turns your src/routes/ directory into virtual modules, generates TypeScript definitions on save, and runs a high-performance HTTP server during development and production.
Installation
Install the router plugin, Vite, and the srvx server runtime:
bash pnpm add @taserjs/router pnpm add -D @taserjs/router-plugin vite srvx
Basic Configuration
Add the taser() plugin to vite.config.ts:
import { defineConfig } from "vite";
import { taser } from "@taserjs/router-plugin/vite";
export default defineConfig({
plugins: [taser()],
});Execution Modes
The Vite plugin supports two operational modes:
1. Standalone Mode (Default)
When used without Nitro, Taser operates as a self-contained server application powered directly by Vite:
- Development: Instant HMR and route discovery with zero rebuild steps.
- Production: Compiles an optimized server bundle to
dist/.
To build and run in production:
vite build
node dist/serve.mjs2. Nitro Mode (Vite + Nitro)
When paired with nitro/vite, Taser automatically attaches its Nitro module hook:
import { defineConfig } from "vite";
import { nitro } from "nitro/vite";
import { taser } from "@taserjs/router-plugin/vite";
export default defineConfig({
plugins: [taser(), nitro()],
});In this mode, Nitro handles production artifact packaging according to your chosen nitro.config.ts deployment preset (e.g. Node Server, Cloudflare Workers, Vercel, AWS Lambda).
Plugin Options
The taser() plugin accepts optional configuration:
import { defineConfig } from "vite";
import { taser } from "@taserjs/router-plugin/vite";
export default defineConfig({
plugins: [
taser({
basePath: "/api/v1",
routesDir: "src/routes",
entryPath: "src/taser.ts",
server: true,
}),
],
});Configuration Reference
Prop
Type
Virtual Modules
The Vite plugin exposes virtual modules that resolve routing logic without writing intermediate code to disk:
#taserjs/virtual/manifest: Dynamically builds the static radix routing manifest tree.#taserjs/virtual/entry: Assembles the root request handler wrapping context and routes.#taserjs/virtual/app: Composes Taser with optional host framework pass-through and 404 handlers.
Ambient Route Types
During development, the plugin watches src/routes/ and generates TypeScript declaration files in .taser/types/.
To ensure your editor recognizes all route types, verify your tsconfig.json includes this directory:
{
"compilerOptions": {
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"strict": true
},
"include": ["src", ".taser/types/**/*.d.ts"]
}Next Steps
TanStack Start
Integrate Taser with TanStack Start fullstack applications and React Query.
Next.js Plugin
Embed Taser directly inside Next.js App Router applications.
Nitro Module
Learn how Taser pairs with Nitro for edge and multi-cloud deployments.
Deployment Presets
Deploy your Vite backend to Cloudflare, Vercel, Node, and AWS Lambda.
Next.js App Router
Build fullstack Next.js 15+ App Router applications with a dedicated Taser REST API subsystem. Type-safe data fetching in React Server Components, Server Actions, and Client Components.
Next.js Plugin
Configure the @taserjs/router-plugin/next bundler plugin for Next.js 15+ App Router. Options, disk artifact generation, and Turbopack/Webpack compilation.