Packages
@dudousxd/nestjs-inertia-vite
Vite plugin and dev-server middleware bridge for NestJS.
pnpm add @dudousxd/nestjs-inertia-vite
pnpm add -D vite @vitejs/plugin-reactnpm install @dudousxd/nestjs-inertia-vite
npm install --save-dev vite @vitejs/plugin-reactyarn add @dudousxd/nestjs-inertia-vite
yarn add -D vite @vitejs/plugin-reactBridges NestJS and Vite so that HMR, React Fast Refresh, and the Vite manifest work transparently.
Exports
| 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
// vite.config.ts
import { defineConfig } from 'vite';
import { nestInertia } from '@dudousxd/nestjs-inertia-vite';
export default defineConfig({
plugins: [
nestInertia({
react: true,
root: '.',
entry: 'inertia/app.tsx',
}),
],
});| Option | Default | Description |
|---|---|---|
react / vue / svelte | none | Enable the framework transform |
root | 'inertia' | Vite root directory |
entry | 'inertia/app/client.tsx' | Client entry point |
If you set build.rollupOptions.input or root in your Vite config directly, those win. The plugin respects user overrides.
Dev-server bootstrap
// src/main.ts
import { setupInertiaVite } from '@dudousxd/nestjs-inertia-vite';
const app = await NestFactory.create(AppModule);
await setupInertiaVite(app, {
mode: process.env.NODE_ENV ?? 'development',
root: 'inertia',
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.
See the Getting Started guide for a full setup walkthrough.