---
title: Introduction
description: fastrs is a thin ergonomics layer on Axum 0.7 that adds compile-time OpenAPI generation, automatic request validation, and minimal boilerplate for Rust web APIs.
url: https://fast-rs.thally.app/
---

# Introduction

fastrs is a thin ergonomics layer on Axum 0.7 that adds compile-time OpenAPI generation, automatic request validation, and minimal boilerplate for Rust web APIs.

fastrs brings FastAPI-style developer experience to Rust. It wraps
[Axum 0.7](https://docs.rs/axum/0.7) with proc macros that generate OpenAPI
schemas and validate requests at compile time, so your handlers stay short and
your binary pays no runtime reflection cost.

## Crate structure

The project is a Cargo workspace with three crates.

| Crate | Role |
|---|---|
| `fastrs` | Facade crate. Re-exports everything from `fastrs-core` and `fastrs-macros`. Add this to your `[dependencies]` for the simplest setup. |
| `fastrs-core` | Runtime library. Contains `App`, extractors, error types, response wrappers, middleware helpers, and the OpenAPI registry. Built on Axum 0.7, Tower 0.5, and Serde. |
| `fastrs-macros` | Proc-macro crate. Provides `#[derive(OpenApi)]` for compile-time schema generation and route attribute macros (`#[get]`, `#[post]`, `#[put]`, `#[patch]`, `#[delete]`). |

Depend on the facade and you get everything in one import:

```rust
// Cargo.toml
[dependencies]
fastrs = "0.1"
serde = { version = "1.0", features = ["derive"] }
validator = { version = "0.18", features = ["derive"] }
tokio = { version = "1", features = ["rt-multi-thread", "macros"] }
```

## What it provides

- **Compile-time OpenAPI docs.** `#[derive(OpenApi)]` reads struct fields and
  `#[validate(...)]` attributes at compile time to produce a schema baked into
  the binary. `App::serve_docs_at` serves Swagger UI from that schema with no
  startup scan.
- **Automatic request validation.** `Json<T>`, `Query<T>`, and other extractors
  deserialize and call `Validate::validate()` before your handler runs. Invalid
  input returns a structured 422 response immediately.
- **Route macros.** `#[get("/path")]`, `#[post("/path")]`, and siblings generate
  a `RouteDef` that registers the Axum handler and its OpenAPI operation in one
  step.
- **Built-in middleware.** CORS, tracing, request IDs, and rate limiting are
  available as one-liner `App` methods, and `App::layer` exposes the full Tower
  middleware stack.
- **Auth and pagination extractors.** `Bearer<T>` with a pluggable
  `AuthVerifier` trait and `Page` with default/bounds handling are included out
  of the box.
- **HTMX support.** Enable the optional `htmx` feature for `HxRequest`,
  `HxTarget`, `HxTrigger` extractors and `HxRedirect`, `HxRefresh` responders.

## Comparison with Axum and FastAPI

| Feature | fastrs | Axum | FastAPI |
|---|---|---|---|
| Boilerplate | Minimal (like FastAPI) | High (manual validation and schema wiring) | Minimal |
| OpenAPI generation | Compile-time via macros | Not built-in (third-party crates such as `utoipa`) | Runtime via reflection |
| Request validation | Automatic, compile-time | Manual inside handler | Automatic |
| Runtime overhead | Zero | Zero | High (Python) |
| Routing abstraction | Returns a raw `axum::Router` | Native | Custom |
| Auth support | `Bearer` extractor with `AuthVerifier` trait | Manual | OpenAPI auth schemes |
| Pagination | First-class `Page` extractor | Manual query parsing | Built-in |

## License

fastrs is dual-licensed under MIT OR Apache-2.0.

## Next steps

#### [Quickstart](/quickstart)

    Set up a project, define a validated endpoint, and run Swagger UI in minutes.

#### [App builder](/api/app-builder)

    Configure routes, middleware, state, and graceful shutdown with the App API.

#### [Extractors](/api/extractors)

    Learn how Json, Query, Path, Bearer, Page, Header, and Multipart work.

#### [OpenAPI](/api/openapi)

    Understand how schemas, operations, and Swagger UI are generated at compile time.