Fastify Integration
Pair Taser file routing with Fastify. Coexist with Fastify plugins, hooks, and native route handlers using host pass-through architecture.
Taser integrates with Fastify applications using the Host Pass-Through Architecture. You can run Fastify plugins, hooks, and legacy endpoints alongside Taser's file-based route tree.
How It Works
- Taser First: Taser evaluates requests against
src/routes/. - Fastify Fall-Through: Unmatched requests fall through to Fastify's internal router.
- 404 Handling: If neither handles the request, Taser returns 404 Not Found.
Quickstart
1. Scaffold with Fastify Host
pnpm create taserjs@latest my-fastify-app --framework fastify -y2. Configure src/server.node.ts
Create src/server.node.ts exporting Fastify's routing handler:
import Fastify from "fastify";
const app = Fastify({ logger: true });
// Existing Fastify endpoints:
app.get("/fastify-legacy", async () => {
return { framework: "Fastify", status: "online" };
});
// Ensure Fastify plugins and routes are loaded before export:
await app.ready();
export default app.routing;3. Add Taser Routes
Create src/routes/health.get.ts:
import { json } from "@taserjs/router/reply";
import { t } from "@taserjs/router";
const GET = t.get("/health");
export default GET.handler(() => {
return json({ ok: true, timestamp: Date.now() });
});4. Start Development
pnpm devNext Steps
Express Integration
Add Taser file-based routing to an Express application. Coexist with legacy controllers and middleware using the host pass-through architecture.
TanStack Start
Build fullstack React applications with TanStack Start and Taser. Type-safe data fetching in TanStack Router loaders, React Query, and multi-runtime Nitro deployment.