Skip to content

@dudousxd/nestjs-inertia (core)

Terminal window
pnpm add @dudousxd/nestjs-inertia

The heart of the system. Implements the Inertia.js protocol as a NestJS module.

ExportDescription
InertiaModule.forRoot(options)Registers the module globally; sets root view, version, and shared props
InertiaModule.forRootAsync(options)Async variant (useFactory, useClass, useExisting)
InertiaModule.forFeature(options)Registers an additional scope with its own view/shared props
@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
InertiaAuthGuardRemoved — see auth-redirect recipe
InertiaNotFoundFilterRemoved — see not-found recipe
ErrorBagInterceptorNamespaces errors by X-Inertia-Error-Bag header
CsrfCookieInterceptorSets XSRF-TOKEN cookie and validates X-XSRF-TOKEN
InertiaModule.forRoot({
rootView: 'inertia/root.html', // path to HTML shell (relative to cwd)
version: '1', // asset version for cache-busting
})

See the Getting Started guide for a full bootstrap example.