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.
Commands overview
Section titled “Commands overview”| Command | Description |
|---|---|
inertia install | Scaffold the Inertia directory structure and starter files |
inertia dev | Start the Vite development server with HMR |
inertia build | Build client and SSR bundles for production |
inertia types | Generate TypeScript types for page components |
Run npx inertia --help to see the same summary in your terminal.
inertia install
Section titled “inertia install”Scaffolds the Inertia directory structure and creates starter files so you can begin building immediately.
npx inertia installThis creates the following files:
| File | Purpose |
|---|---|
src/inertia/app.tsx | Client-side entry point |
src/inertia/root.html | Root HTML template |
src/inertia/pages/Home.tsx | Sample page component |
src/inertia/public/.gitkeep | Public 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.
| Flag | Description |
|---|---|
--skip-deps | Skip printing the dependency install hint at the end. |
inertia dev
Section titled “inertia dev”Starts the Vite development server with hot module replacement.
npx inertia dev| Flag | Default | Description |
|---|---|---|
--port | 5173 | Port for the Vite development server. |
--host | — | Expose the dev server to your local network. |
--persist-to | — | Path to persist Cloudflare Workers state between dev runs. |
Example
Section titled “Example”npx inertia dev --port=3000 --hostinertia build
Section titled “inertia build”Builds the client bundle and, optionally, the SSR bundle for production deployment.
npx inertia build| Flag | Default | Description |
|---|---|---|
--out-dir | dist | Output directory for the build. |
--ssr | — | Also build the SSR bundle. |
Examples
Section titled “Examples”Build both client and SSR bundles:
npx inertia build --ssrBuild to a custom output directory:
npx inertia build --out-dir=buildinertia types
Section titled “inertia types”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.
npx inertia types| Flag | Description |
|---|---|
--watch | Regenerate types automatically when page files change. |
Example
Section titled “Example”Run in watch mode during development:
npx inertia types --watch