Aviary
Packages

@dudousxd/nestjs-inertia (core)

Core NestJS module, @Inertia decorator, InertiaService, and version negotiation.

pnpm add @dudousxd/nestjs-inertia
npm install @dudousxd/nestjs-inertia
yarn add @dudousxd/nestjs-inertia

Implements the Inertia.js protocol as a NestJS module. Handles page rendering, version negotiation, shared props, SSR, CSRF, and redirects.

Exports

ExportDescription
InertiaModule.forRoot(options)Global module registration; sets root view, version, shared props
InertiaModule.forRootAsync(options)Async variant (useFactory, useClass, useExisting)
InertiaModule.forFeature(options)Register an additional scope with its own view/shared props
InertiaModule.forFeatureAsync(options)Async variant for feature scopes
@Inertia(component)Method decorator; intercepts return value, renders Inertia response
@UseInertia(scope)Controller/method decorator; selects a forFeature scope
InertiaServiceInjectable service for programmatic renders and redirects
Inertia.always(fn)Prop marker; always resolved, even on partial reloads
Inertia.optional(fn)Prop marker; resolved only when explicitly requested
Inertia.defer(fn, group?)Prop marker; deferred to a separate request
Inertia.merge(fn, opts?)Prop marker; appended/prepended on reload
Inertia.once(fn)Prop marker; resolved once, then cached
ErrorBagInterceptorNamespaces errors by X-Inertia-Error-Bag header
CsrfCookieInterceptorSets XSRF-TOKEN cookie and validates X-XSRF-TOKEN
CsrfGuardGuard-based CSRF validation
RedirectInterceptorConverts 302 to 303 for PUT/PATCH/DELETE per Inertia spec
MethodSpoofMiddleware_method field support for HTML form method spoofing

Minimal setup

import { resolve } from 'node:path';

InertiaModule.forRoot({
  rootView: resolve(__dirname, '../inertia/root.html'),
  version: '1',
})

See the Getting Started guide for a full bootstrap example.

On this page