Skip to main content
The kit serve command starts both the backend Rust server and the frontend Vite development server with hot-reload support.

Usage

kit serve [options]

Options

OptionDefaultDescription
-p, --port <PORT>8000Backend server port
--frontend-port <PORT>5173Frontend Vite server port
--backend-onlyfalseOnly start the backend server
--frontend-onlyfalseOnly start the frontend server
--skip-typesfalseSkip TypeScript type generation

Examples

Start Both Servers

kit serve
Starts:
  • Backend server on http://localhost:8000
  • Frontend Vite server on http://localhost:5173
  • Watches for changes and auto-rebuilds
  • Generates TypeScript types from Rust structs

Custom Ports

kit serve --port 3000 --frontend-port 3001

Backend Only

kit serve --backend-only
Useful when:
  • Working on API-only features
  • Frontend is deployed separately
  • Running in production mode

Frontend Only

kit serve --frontend-only
Useful when:
  • Backend is running elsewhere
  • Testing frontend in isolation

Skip Type Generation

kit serve --skip-types
Skips the automatic TypeScript type generation from Rust InertiaProps structs. Useful if you’re managing types manually.

How It Works

When you run kit serve, the CLI:
  1. Builds the Rust backend - Compiles your application in debug mode
  2. Generates TypeScript types - Scans for InertiaProps structs and generates corresponding TypeScript interfaces
  3. Starts the backend server - Runs your Rust application with hot-reload using cargo watch
  4. Starts the frontend server - Runs Vite development server with HMR (Hot Module Replacement)

Development Workflow

# Terminal 1: Start the full development environment
kit serve

# Make changes to your Rust code - backend auto-rebuilds
# Make changes to your React code - frontend auto-updates

# Terminal 2: Generate migrations, run them
kit make:migration create_users_table
kit migrate

Environment Variables

The serve command respects environment variables from .env:
# .env
DATABASE_URL=sqlite:./database.db
APP_PORT=8000
APP_HOST=127.0.0.1

Troubleshooting

Port Already in Use

If you see a port conflict error:
# Find and kill the process using the port
lsof -i :8000
kill -9 <PID>

# Or use a different port
kit serve --port 8001

Frontend Not Connecting

Ensure your frontend is configured to proxy to the correct backend port in vite.config.ts.