Skip to content

CLI Commands

@stratal/inertia ships a standalone CLI that scaffolds, runs, builds, and generates types for your Inertia application. The binary is exposed as inertia, so you can invoke it with npx inertia <command> from any project that has @stratal/inertia installed.

CommandDescription
inertia installScaffold the Inertia directory structure and starter files
inertia devStart the Vite development server with HMR
inertia buildBuild client and SSR bundles for production
inertia typesGenerate TypeScript types for page components

Run npx inertia --help to see the same summary in your terminal.

Scaffolds the Inertia directory structure and creates starter files so you can begin building immediately.

Terminal window
npx inertia install

This creates the following files:

FilePurpose
src/inertia/app.tsxClient-side entry point
src/inertia/root.htmlRoot HTML template
src/inertia/pages/Home.tsxSample page component
src/inertia/public/.gitkeepPublic assets directory

If src/app.module.ts exists, the command also adds an InertiaModule.forRoot({ rootView }) import to your module — skipping the change if it’s already configured.

FlagDescription
--skip-depsSkip printing the dependency install hint at the end.

Starts the Vite development server with hot module replacement.

Terminal window
npx inertia dev
FlagDefaultDescription
--port5173Port for the Vite development server.
--hostExpose the dev server to your local network.
--persist-toPath to persist Cloudflare Workers state between dev runs.
Terminal window
npx inertia dev --port=3000 --host

Builds the client bundle and, optionally, the SSR bundle for production deployment.

Terminal window
npx inertia build
FlagDefaultDescription
--out-dirdistOutput directory for the build.
--ssrAlso build the SSR bundle.

Build both client and SSR bundles:

Terminal window
npx inertia build --ssr

Build to a custom output directory:

Terminal window
npx inertia build --out-dir=build

Generates TypeScript type definitions for your page components. It scans src/inertia/pages/ for React components and produces types for the page registry, enabling type-safe rendering from your controllers.

Terminal window
npx inertia types
FlagDescription
--watchRegenerate types automatically when page files change.

Run in watch mode during development:

Terminal window
npx inertia types --watch