32 releases (11 breaking)

0.12.0 Oct 28, 2024
0.10.1 Oct 13, 2024
0.6.2 Jul 23, 2024
0.3.2 Mar 6, 2024
0.1.0 Nov 23, 2023

#22 in HTTP server

Download history 4827/week @ 2024-07-28 5236/week @ 2024-08-04 5049/week @ 2024-08-11 5223/week @ 2024-08-18 6047/week @ 2024-08-25 2665/week @ 2024-09-01 2025/week @ 2024-09-08 3940/week @ 2024-09-15 5498/week @ 2024-09-22 6589/week @ 2024-09-29 7873/week @ 2024-10-06 9556/week @ 2024-10-13 9380/week @ 2024-10-20 10149/week @ 2024-10-27 11360/week @ 2024-11-03 10907/week @ 2024-11-10

43,264 downloads per month
Used in 3 crates

Apache-2.0

1MB
10K SLoC

Welcome to Loco

🚂 Loco is Rust on Rails.

crate docs Discord channel

English · 中文 · Français · Portuguese (Brazil)日本語

What's Loco?

Loco is strongly inspired by Rails. If you know Rails and Rust, you'll feel at home. If you only know Rails and new to Rust, you'll find Loco refreshing. We do not assume you know Rails.

For a deeper dive into how Loco works, including detailed guides, examples, and API references, check out our documentation website.

Features of Loco:

  • Convention Over Configuration: Similar to Ruby on Rails, Loco emphasizes simplicity and productivity by reducing the need for boilerplate code. It uses sensible defaults, allowing developers to focus on writing business logic rather than spending time on configuration.

  • Rapid Development: Aim for high developer productivity, Loco’s design focuses on reducing boilerplate code and providing intuitive APIs, allowing developers to iterate quickly and build prototypes with minimal effort.

  • ORM Integration: Model your business with robust entities, eliminating the need to write SQL. Define relationships, validation, and custom logic directly on your entities for enhanced maintainability and scalability.

  • Controllers: Handle web requests parameters, body, validation, and render a response that is content-aware. We use Axum for the best performance, simplicity, and extensibility. Controllers also allow you to easily build middlewares, which can be used to add logic such as authentication, logging, or error handling before passing requests to the main controller actions.

  • Views: Loco can integrate with templating engines to generate dynamic HTML content from templates.

  • Background Jobs: Perform compute or I/O intensive jobs in the background with a Redis backed queue, or with threads. Implementing a worker is as simple as implementing a perform function for the Worker trait.

  • Scheduler: Simplifies the traditional, often cumbersome crontab system, making it easier and more elegant to schedule tasks or shell scripts.

  • Mailers: A mailer will deliver emails in the background using the existing loco background worker infrastructure. It will all be seamless for you.

  • Storage: In Loco Storage, we facilitate working with files through multiple operations. Storage can be in-memory, on disk, or use cloud services such as AWS S3, GCP, and Azure.

  • Cache: Loco provides an cache layer to improve application performance by storing frequently accessed data.

So see more Loco features, check out our documentation website.

Getting Started

cargo install loco-cli
cargo install sea-orm-cli # Only when DB is needed

Now you can create your new app (choose "SaaS app").

 loco new
 ❯ App name? · myapp
 ❯ What would you like to build? · SaaS app (with DB and user auth)
 ❯ Select a DB Provider · Sqlite
 ❯ Select your background worker type · Async (in-process tokio async tasks)
 ❯ Select an asset serving configuration · Client (configures assets for frontend serving)

🚂 Loco app generated successfully in:
myapp/

Now cd into your myapp and start your app:

$ cargo loco start

                      
                                
                         ▀     ▄  ▄ ▄▀
                                     ▀▄▄
                             ▀    ▀  ▀▄▀█▄
                                          ▀█▄
▄▄▄▄▄▄▄  ▄▄▄▄▄▄▄▄▄   ▄▄▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄ ▀▀█
██████  █████   ███ █████   ███ █████   ███ ▀█
██████  █████   ███ █████   ▀▀▀ █████   ███ ▄█▄
██████  █████   ███ █████       █████   ███ ████▄
██████  █████   ███ █████   ▄▄▄ █████   ███ █████
██████  █████   ███  ████   ███ █████   ███ ████▀
  ▀▀▀██▄ ▀▀▀▀▀▀▀▀▀▀  ▀▀▀▀▀▀▀▀▀▀  ▀▀▀▀▀▀▀▀▀▀ ██▀
      ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
                https://loco.rs

listening on port 5150

Powered by Loco

  • SpectralOps - various services powered by Loco framework
  • Nativish - app backend powered by Loco framework

Contributors ✨

Thanks goes to these wonderful people:

Dependencies

~39–80MB
~1.5M SLoC