Getting Started
Relevant source files
The following files were used as context for generating this wiki page:
Loco is a "productivity-first" full-stack web framework for Rust, strongly inspired by Ruby on Rails. It is designed to empower solo developers or small teams to build and deploy web applications—ranging from simple REST APIs to complex SaaS platforms—from zero to production with minimal boilerplate and maximum efficiency.
The framework emphasizes "Convention Over Configuration," providing sensible defaults for common tasks such as database migrations, background jobs, and asset serving. By utilizing Rust's performance and safety alongside an intuitive API, Loco enables rapid development without sacrificing scalability.
Sources: README.md:27-38, README.fr.md:27-38, CONTRIBUTING.md:9-11
Installation and Environment Setup
To begin developing with Loco, developers must install the Loco CLI and optionally the SeaORM CLI if database features are required.
cargo install loco
cargo install sea-orm-cli # Only when DB is needed
Sources: README.md:81-84, snipdoc.yml:15-18
System Verification
Before starting development, it is recommended to run the doctor command to ensure all necessary local resources (such as Database and Redis) are correctly configured and reachable.
cargo loco doctor
Sources: DEVELOPMENT.md:37-39, snipdoc.yml:92-100
Environment Checks
| Resource | Tool/Command | Purpose |
|---|---|---|
| Loco CLI | loco --version | Framework management and scaffolding |
| Database | cargo loco doctor | Verifies SeaORM and DB connection |
| Redis | cargo loco doctor | Verifies background worker queue connection |
| Rust Environment | cargo test | Ensures the local toolchain is functional |
Sources: DEVELOPMENT.md:37-41, snipdoc.yml:92-100, CONTRIBUTING.md:65-66
Project Creation and Scaffolding
Loco provides a guided CLI for generating new projects based on predefined templates or "starters."
Creating a New App
Running loco new initiates an interactive prompt to configure the application type, database provider, and background worker type.
Development Templates
Available starters include:
- SaaS App: Includes database integration and user authentication.
- REST API: Optimized for headless services with user management.
- Lightweight Service: Minimalist setup containing only controllers and views.
Sources: docs-site/content/blog/deploy-aws.md:22-29, docs-site/content/blog/frontend-website.md:32-35
Development Workflow
Once a project is generated, the developer follows a standard lifecycle of starting the server, scaffolding features, and managing the database.
Initializing the Server
The server is started using the cargo loco start command, which defaults to listening on port 5150.
$ cargo loco start
listening on port 5150
Sources: README.md:107-133, snipdoc.yml:71-90
Scaffolding CRUD
Loco can generate a full CRUD (Create, Read, Update, Delete) implementation, including models, controllers, and migrations, using a single command.
cargo loco generate scaffold post title:string content:text
Sources: snipdoc.yml:106-110, docs-site/content/casts/003-scaffolding-crud-with-html.md:1-5
Database Management
Loco uses SeaORM for entity management. Common operations include resetting the database and generating entities from the schema.
Sources: DEVELOPMENT.md:23-32, snipdoc.yml:116-120
Frontend Integration
Loco supports various frontend configurations, including server-side rendering (Tera), HTMX, or separate client-side apps (React, Angular).
Serving Static Assets
To serve a compiled frontend (e.g., from Vite or Angular), the static middleware must be enabled in config/development.yaml.
server:
middlewares:
static:
enable: true
must_exist: true
folder:
uri: "/"
path: "frontend/dist"
fallback: "frontend/dist/index.html"
Sources: docs-site/content/blog/frontend-website.md:84-93, docs-site/content/blog/angular-frontend.md:58-65
Development Hot Reloading
For a seamless development experience, cargo-watch can be used to reload the Rust server while a frontend dev server (like Vite) handles UI updates.
cargo watch --ignore "frontend" -x check -s 'cargo run start'
Sources: docs-site/content/blog/frontend-website.md:118-122
Summary
Getting started with Loco involves setting up the Rust environment, installing the loco CLI, and utilizing built-in generators to bootstrap applications. The framework provides a comprehensive toolkit—from database management with SeaORM to deployment configuration—allowing developers to transition rapidly from initial scaffolding to a production-ready environment.
Sources: README.md:37-77, CONTRIBUTING.md:9-11