Skip to main content
This guide covers the development workflow for building Kit applications, including the dev server, hot reloading, and useful commands.

Development Server

Start the development server with:
kit serve
This starts:
  • Backend server on http://localhost:8080
  • Vite dev server on http://localhost:5173 (for frontend assets)

Backend Only Mode

If you only need the Rust backend (no frontend):
kit serve --backend-only

Custom Ports

Configure ports using environment variables:
# .env
PORT=3000
VITE_DEV_SERVER=http://localhost:5174

Project Structure

A typical Kit project structure:
my-app/
├── src/
│   ├── main.rs           # Application entry point
│   ├── routes.rs         # Route definitions
│   ├── controllers/      # Request handlers
│   ├── models/           # Database entities
│   ├── actions/          # Business logic
│   └── middleware/       # Custom middleware
├── frontend/
│   ├── src/
│   │   ├── main.tsx      # Frontend entry
│   │   └── pages/        # React components
│   ├── package.json
│   └── vite.config.ts
├── migrations/           # Database migrations
├── .env                  # Environment config
└── Cargo.toml

Development Workflow

1. Make Changes

Edit your Rust code in src/ or React code in frontend/src/.

2. Automatic Recompilation

Kit watches for changes:
  • Rust changes: Recompiles automatically
  • React changes: Hot module replacement (instant updates)

3. Test Your Changes

Visit http://localhost:8080 to see your changes.

Database Development

Running Migrations

# Run all pending migrations
kit migrate

# Check migration status
kit migrate:status

# Rollback last migration
kit migrate:rollback

Syncing Entities

After modifying migrations, regenerate entity files:
kit db:sync

Fresh Database

Reset and re-run all migrations:
kit migrate:fresh

Code Generation

Kit provides generators to scaffold common components:
# Create a controller
kit make:controller users

# Create a model
kit make:model User

# Create a migration
kit make:migration create_posts_table

# Create a page component
kit make:page Home

# Generate TypeScript types
kit generate-types

Environment Configuration

Configure your app using .env:
# Server
PORT=8080

# Database
DATABASE_URL=sqlite:./database.db

# Inertia/Frontend
INERTIA_DEVELOPMENT=true
VITE_DEV_SERVER=http://localhost:5173

Debugging

Logging

Kit uses Rust’s standard logging. Enable debug output:
RUST_LOG=debug kit serve

Database Queries

Enable SQL query logging:
RUST_LOG=sea_orm=debug kit serve

Testing

Run your test suite:
cargo test

Frontend Tests

cd frontend
npm test

Building for Production

Build the Backend

cargo build --release

Build the Frontend

cd frontend
npm run build

Run Production Server

INERTIA_DEVELOPMENT=false ./target/release/your-app

Useful Commands

CommandDescription
kit serveStart dev server
kit serve --backend-onlyStart without Vite
kit migrateRun migrations
kit migrate:freshReset database
kit db:syncRegenerate entities
kit make:controller <name>Create controller
kit make:model <name>Create model
kit generate-typesGenerate TS types
cargo build --releaseProduction build