Vite Plugin
Integrate Taser.js with Vite using @taserjs/plugin/vite. Manifest generation, HMR, and standalone or Nitro-backed builds.
The @taserjs/plugin/vite package connects Taser.js file routing to Vite. It regenerates src/.taserjs/routes.gen.ts on change, enables HMR for routes, and can run a dedicated HTTP server in development and production.
Installation
Install the router, plugin, Vite, and the srvx server runtime:
bash pnpm add @taserjs/router pnpm add -D @taserjs/plugin @taserjs/cli vite srvx
Basic Configuration
Paths (serverDir, routesDir, outputDir, app) belong in taserjs.config.ts. The Vite plugin turns generation and the optional HTTP server on:
import { defineConfig } from "@taserjs/cli";
export default defineConfig({
serverDir: "src",
routesDir: "routes",
outputDir: ".taserjs",
app: "taser.ts",
});import { defineConfig } from "vite";
import { taser } from "@taserjs/plugin/vite";
export default defineConfig({
plugins: [taser()],
});Mount URL prefixes with defineTaser().basePath(...) in your app definition, not in the Vite plugin options. Point @taserjs/client at the same prefix with baseUrl.
Execution Modes
1. Standalone Mode (Default)
Without Nitro, Taser.js runs as a self-contained server powered by Vite:
- Development: Route discovery and HMR with no separate generate step.
- Production: Optimized server bundle under
dist/.
vite build
node dist/serve.mjs2. Nitro Mode (Vite + Nitro)
Pair taser() with nitro() when Nitro should package the deployment:
import { defineConfig } from "vite";
import { nitro } from "nitro/vite";
import { taser } from "@taserjs/plugin/vite";
export default defineConfig({
plugins: [taser(), nitro()],
});Nitro uses your nitro.config.ts preset (Node, Cloudflare Workers, Vercel, AWS Lambda, and so on).
Plugin Options
import { defineConfig } from "vite";
import { taser } from "@taserjs/plugin/vite";
export default defineConfig({
plugins: [
taser({
server: true,
serverEntry: "src/server.ts",
config: "./taserjs.config.ts",
}),
],
});Prop
Type
Where do routesDir and serverDir go?
Set serverDir, routesDir, outputDir, and app in taserjs.config.ts. The
plugin loads that file (or built-in defaults) during generate and watch.
Generated Manifest
During development and builds, the plugin writes src/.taserjs/routes.gen.ts (path follows serverDir + outputDir): compiled app, ambient route types, and the composite manifest for @taserjs/client.
{
"compilerOptions": {
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"strict": true
},
"include": ["src/**/*", "vite.config.ts"]
}Next Steps
TanStack Start
Integrate Taser.js with TanStack Start fullstack applications and React Query.
Next.js Plugin
Embed Taser.js inside Next.js App Router applications.
Nitro Module
Pair Taser.js 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.js REST API subsystem. Type-safe data fetching in React Server Components, Server Actions, and Client Components.
Next.js Plugin
Configure @taserjs/plugin/next for Next.js 15+ App Router: createTaser with cwd/config, and routes.gen.ts generation.