Next.js Plugin
Configure @taserjs/plugin/next for Next.js 15+ App Router: createTaser with cwd/config, and routes.gen.ts generation.
The @taserjs/plugin/next package hooks Taser.js into Next.js 15+ App Router builds. It generates ${serverDir}/.taserjs/routes.gen.ts from taserjs.config.ts and wires Webpack/Turbopack so routes stay in sync during next dev and next build.
Looking for the Fullstack Next.js Guide?
For RSC patterns and Server Actions recipes, see the Next.js App Router Fullstack Guide.
Installation
Install @taserjs/plugin and @taserjs/cli as development dependencies:
bash pnpm add -D @taserjs/plugin @taserjs/cli Put path layout in taserjs.config.ts:
import { defineConfig } from "@taserjs/cli";
export default defineConfig({
serverDir: "src/server",
routesDir: "routes",
outputDir: ".taserjs",
app: "taser.ts",
});Basic Configuration
Wrap next.config.ts with createTaser (or withTaser). Plugin options are only cwd and config:
import type { NextConfig } from "next";
import { createTaser } from "@taserjs/plugin/next";
const nextConfig: NextConfig = {
reactStrictMode: true,
};
const withTaser = createTaser();
export default withTaser(nextConfig);Optional overrides:
import { createTaser } from "@taserjs/plugin/next";
const withTaser = createTaser({
config: "./taserjs.config.ts",
});
export default withTaser({
reactStrictMode: true,
});Set the HTTP mount with defineTaser().basePath("/api") in src/server/taser.ts, and point the client baseUrl at the same prefix (for example "/api").
Plugin Options
createTaser accepts NextTaserOptions:
Prop
Type
serverDir, routesDir, outputDir, app, and extension come from taserjs.config.ts. Runtime URL prefixes use defineTaser().basePath(...), not plugin options.
How It Works
- Watches
${serverDir}/routes/duringnext devand regenerates on change (with scaffolding for empty files). - Writes
${serverDir}/.taserjs/routes.gen.ts: compiledapp, ambient route types, and the composite manifest for@taserjs/client. - Hooks Webpack (and keeps Turbopack in sync via the watcher) so builds always see a fresh manifest.