# Tide — Async Web Framework for Rust > Tide is an asynchronous web framework for Rust that provides a minimal, composable API inspired by Express and Koa for building HTTP servers with async/await and the async-std runtime. ## Install Save in your project root: # Tide — Async Web Framework for Rust ## Quick Use ```toml # Cargo.toml [dependencies] tide = "0.16" async-std = { version = "1", features = ["attributes"] } ``` ```rust #[async_std::main] async fn main() -> tide::Result<()> { let mut app = tide::new(); app.at("/").get(|_| async { Ok("Hello, Tide!") }); app.listen("127.0.0.1:8080").await?; Ok(()) } ``` ## Introduction Tide is an async web framework for Rust built on the async-std runtime. It provides a small, composable API for defining HTTP endpoints with middleware, state management, and streaming support. Tide aims to make async Rust web development approachable by offering a clean, Express-inspired interface. ## What Tide Does - Defines HTTP routes with async handler functions that return Result types - Supports middleware composition for logging, CORS, sessions, and error handling - Manages application state via a shared State type available in all handlers - Handles streaming request and response bodies for large payloads - Provides built-in support for JSON, form data, and file serving ## Architecture Overview Tide is built on async-std and http-types. Requests flow through a middleware stack, then match against a route trie. Each handler receives a Request object containing the shared application state, extracts parameters or body data, and returns a Response. The framework is single-threaded per listener by default but can be wrapped in multi-listener setups for concurrency. ## Self-Hosting & Configuration - Requires Rust 1.65+ with the 2021 edition - Add `tide` and `async-std` to Cargo.toml dependencies - Initialize with `tide::new()` or `tide::with_state(state)` for shared state - Bind to address with `app.listen("0.0.0.0:8080").await` - Deploy as a compiled binary; pair with a reverse proxy for TLS ## Key Features - Clean async/await API reduces the complexity of asynchronous Rust code - Shared application state is type-safe and available in every handler - Middleware is composable with before, after, and around hooks - Nested routes and route prefixes keep endpoint definitions organized - Server-Sent Events support for real-time push from server to client ## Comparison with Similar Tools - **Actix Web** — more mature with higher throughput; Tide prioritizes API simplicity - **Axum** — Tokio-based with extractor pattern; Tide uses async-std runtime - **Rocket** — macro-driven with compile-time checks; Tide is more lightweight - **Warp** — filter-based composition; Tide uses traditional route-and-handler style - **Poem** — feature-rich with OpenAPI support; Tide is more minimal ## FAQ **Q: Why does Tide use async-std instead of Tokio?** A: Tide was built by the async-std team as a showcase for the runtime. It embraces async-std's task model and I/O traits. **Q: Is Tide production-ready?** A: Tide is usable for production workloads but has not reached 1.0. Evaluate stability requirements before choosing it for critical services. **Q: Can I use Tide with Tokio?** A: Tide is designed for async-std. For Tokio-based projects, Axum or Actix Web are better fits. **Q: Does Tide support WebSockets?** A: WebSocket support is available via the `tide-websockets` crate as a middleware extension. ## Sources - https://github.com/http-rs/tide - https://docs.rs/tide --- Source: https://tokrepo.com/en/workflows/asset-47377ef8 Author: AI Open Source