Rust Framework
View as MarkdownNeutron for Rust is a modular framework for asynchronous services, background workers, and application backends. Its HTTP core uses Hyper and Tokio, with typed extractors and composable middleware. Optional crates add jobs, database access, storage, and telemetry; Neutron Desktop also uses Rust for its backend.
Use the modules that fit your application alongside the wider Rust ecosystem. Neutron’s current core focuses on networked applications. Choosing Rust gives you control over resources and concurrency; it does not establish that a particular application is faster without measurement.
Features
- Trie routing — Method-aware matching with static, parameter, and wildcard segments
- Type-safe — Extractors for Path, Query, Json, Form, State, Extension
- Composable — Tower-style middleware with zero-allocation chain building
- Full-stack — JWT, OAuth, WebSocket, SSE, PubSub, sessions, CSRF built in
- Feature-gated — Use only what you need (bare core, web, or full)
Hello World
use neutron::prelude::*;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
let router = Router::new()
.get("/", || async { "Hello, Neutron!" })
.get("/users/:id", get_user);
Neutron::new().router(router).serve(3000).await
}
async fn get_user(Path(id): Path<u64>) -> Json<serde_json::Value> {
Json(serde_json::json!({ "id": id, "name": "Alice" }))
}
Crate Architecture
| Crate | Purpose |
|-------|---------|
| neutron | Core framework (router, extractors, middleware, auth, real-time) |
| neutron-cli | CLI for scaffolding, dev server, build |
| neutron-cache | Tiered L1/L2 cache (in-process + Redis) |
| neutron-redis | Redis sessions, rate limiting, HTTP cache |
| neutron-oauth | OAuth2/OIDC with PKCE |
| neutron-webauthn | Passkey/FIDO2 authentication |
| neutron-jobs | Background jobs + cron scheduling |
| neutron-graphql | GraphQL HTTP + WebSocket transport |
| neutron-otel | OpenTelemetry OTLP/JSON tracing |
| neutron-storage | S3/R2/GCS with SigV4 signing |
| neutron-smtp | Transactional email via SMTP |
| neutron-stripe | Stripe payments + webhook verification |
Feature Tiers
# Minimal — just router + extractors
neutron-rs = { version = "0.1", default-features = false }
# Web — standard API server
neutron-rs = { version = "0.1", features = ["web"] }
# Full — batteries included
neutron-rs = { version = "0.1" } # default = "full"
Published on crates.io as
neutron-rs(the bareneutronname is taken). The library is imported asneutron— you writeneutron-rs = "0.1"inCargo.tomlbutuse neutron::...in your code.
Built On
- hyper 1.0 — HTTP/1.1 and HTTP/2
- Tokio — Async runtime
- matchit — Compressed radix tree router
- fastwebsockets — WebSocket
- serde — Serialization