@dudousxd/nestjs-inertia-vite
pnpm add @dudousxd/nestjs-inertia-vitepnpm add -D vite @vitejs/plugin-reactBridges NestJS and Vite’s dev server so that HMR, React Fast Refresh, and the Vite manifest work transparently.
Key API surface
Section titled “Key API surface”| Export | Description |
|---|---|
nestInertia(options) | Vite plugin — configures React/Vue/Svelte transforms + manifest |
setupInertiaVite(app, options) | Attaches Vite dev-server middleware to the NestJS app |
Vite plugin
Section titled “Vite plugin”import { defineConfig } from 'vite';import { nestInertia } from '@dudousxd/nestjs-inertia-vite';
export default defineConfig({ plugins: [ nestInertia({ react: true, // also: vue: true | svelte: true root: '.', // optional — defaults to 'inertia' entry: 'inertia/app.tsx', // optional — defaults to 'inertia/app/client.tsx' }), ], // The plugin only sets root/input if you haven't already — your values win.});The root and entry options override the plugin’s defaults. If you set build.rollupOptions.input or root directly in your Vite config, those win — the plugin respects user overrides.
Dev-server bootstrap
Section titled “Dev-server bootstrap”import { setupInertiaVite } from '@dudousxd/nestjs-inertia-vite';
const app = await NestFactory.create(AppModule);await setupInertiaVite(app, { mode: process.env.NODE_ENV ?? 'development', root: 'inertia', // Vite root (where index.html lives) publicDir: 'dist/inertia/client', outDir: 'dist/inertia',});await app.listen(3000);In development, attaches Vite in middleware mode with HMR. In production, serves hashed assets from publicDir with long cache headers using the Vite manifest.