> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/tokio-rs/axum/llms.txt
> Use this file to discover all available pages before exploring further.

# Installation

> Add Axum to your Rust project and configure the required dependencies

This guide will help you add Axum to your Rust project and configure the necessary dependencies.

## Prerequisites

<Steps>
  <Step title="Install Rust">
    Axum requires Rust 1.80 or later. Install Rust using [rustup](https://rustup.rs/):

    ```bash theme={null}
    curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
    ```

    Verify your installation:

    ```bash theme={null}
    rustc --version
    ```
  </Step>

  <Step title="Create a new project">
    Create a new Rust binary project:

    ```bash theme={null}
    cargo new my-axum-app
    cd my-axum-app
    ```
  </Step>
</Steps>

## Add dependencies

Add Axum and Tokio to your `Cargo.toml`:

<CodeGroup>
  ```toml Minimal setup theme={null}
  [dependencies]
  axum = "0.8.8"
  tokio = { version = "1.0", features = ["full"] }
  ```

  ```toml Production setup theme={null}
  [dependencies]
  axum = { version = "0.8.8", features = ["macros"] }
  tokio = { version = "1.44", features = ["macros", "rt-multi-thread", "net"] }
  tower = "0.5"
  tower-http = { version = "0.6", features = ["trace", "compression-full"] }
  tracing = "0.1"
  tracing-subscriber = { version = "0.3", features = ["env-filter"] }
  serde = { version = "1.0", features = ["derive"] }
  ```

  ```toml With common features theme={null}
  [dependencies]
  axum = { version = "0.8.8", features = ["macros", "multipart", "ws"] }
  tokio = { version = "1.44", features = ["full"] }
  tower = "0.5"
  tower-http = { version = "0.6", features = ["cors", "trace"] }
  serde = { version = "1.0", features = ["derive"] }
  serde_json = "1.0"
  ```
</CodeGroup>

## Core dependencies

### Axum

The main Axum crate provides routing, extractors, and response types.

```toml theme={null}
axum = "0.8.8"
```

<Tip>
  Axum uses semantic versioning. The API is stable, but we recommend pinning to a specific minor version.
</Tip>

### Tokio

Axum requires the Tokio async runtime. At minimum, you need the `net`, `rt`, and `macros` features:

```toml theme={null}
tokio = { version = "1.44", features = ["macros", "rt-multi-thread", "net"] }
```

For development, using the `full` feature set is convenient:

```toml theme={null}
tokio = { version = "1.44", features = ["full"] }
```

<Warning>
  The `tokio` feature is enabled by default in Axum. If you disable default features, you'll need to enable it manually.
</Warning>

## Optional features

Axum provides several optional features you can enable based on your needs:

### JSON support

Enabled by default. Provides `Json` extractor and response:

```toml theme={null}
axum = { version = "0.8.8", features = ["json"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
```

### Macros

Provides derive macros for common patterns:

```toml theme={null}
axum = { version = "0.8.8", features = ["macros"] }
```

### Multipart forms

For handling file uploads:

```toml theme={null}
axum = { version = "0.8.8", features = ["multipart"] }
```

### WebSockets

For WebSocket connections:

```toml theme={null}
axum = { version = "0.8.8", features = ["ws"] }
```

### HTTP/2

Enabled by default. For HTTP/2 support:

```toml theme={null}
axum = { version = "0.8.8", features = ["http2"] }
```

## Tower dependencies

### Tower

Provides core service abstractions:

```toml theme={null}
tower = { version = "0.5.2", features = ["util", "timeout", "limit"] }
```

### Tower-HTTP

Provides HTTP-specific middleware:

```toml theme={null}
tower-http = { version = "0.6.8", features = [
    "trace",           # Request tracing
    "cors",            # CORS handling
    "compression-gzip", # Gzip compression
    "compression-br",  # Brotli compression
    "fs",              # Static file serving
] }
```

<Info>
  Tower-HTTP provides many useful middleware out of the box. Check the [tower-http documentation](https://docs.rs/tower-http) for the complete list.
</Info>

## Observability

For production applications, add tracing:

```toml theme={null}
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
```

This enables structured logging and request tracing when combined with tower-http's `TraceLayer`.

## Complete example

Here's a production-ready `Cargo.toml`:

```toml theme={null}
[package]
name = "my-axum-app"
version = "0.1.0"
edition = "2021"

[dependencies]
# Core
axum = { version = "0.8.8", features = ["macros", "multipart"] }
tokio = { version = "1.44", features = ["macros", "rt-multi-thread", "net"] }

# Tower ecosystem
tower = { version = "0.5.2", features = ["util", "timeout"] }
tower-http = { version = "0.6.8", features = ["trace", "cors", "compression-gzip"] }

# Serialization
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"

# Observability
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
```

## Verify installation

Test that everything is set up correctly:

```bash theme={null}
cargo check
```

You should see output indicating that dependencies are being downloaded and compiled.

<Tip>
  The first build will take longer as Cargo downloads and compiles dependencies. Subsequent builds will be much faster.
</Tip>

## Next steps

<Card title="Quickstart" icon="rocket" href="/quickstart">
  Build your first HTTP server with Axum
</Card>
