Rust Framework

Neutron for Rust is a lightweight async web framework built on hyper 1.0 and Tokio. Type-safe extractors, composable middleware, and built-in auth — with first-class Nucleus integration.

Features

  • Fast — 681ns plaintext, 1.57μs JSON, trie-based routing (277ns lookup with 500 routes)
  • 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 = { version = "0.1", default-features = false }

# Web — standard API server
neutron = { version = "0.1", features = ["web"] }

# Full — batteries included
neutron = { version = "0.1" }  # default = "full"

Built On