<div>
<h1>ntex</h1>
<p><strong>Framework for composable network services.</strong></p>
[](https://github.com/ntex-rs/ntex/actions/workflows/linux.yml)
[](https://crates.io/crates/ntex)
[](https://docs.rs/ntex)
[](https://releases.rs/docs/1.97.0/)
[](https://github.com/ntex-rs/ntex#license)
[](https://codecov.io/gh/ntex-rs/ntex/tree/main)
[](https://discord.gg/4GtaeP5Uqu)
</div>
ntex provides a strongly typed component for building
asynchronous network applications. It includes HTTP/1, HTTP/2, WebSocket,
TLS, and runtime-independent I/O support. MQTT, AMQP, and gRPC are provided
by [related projects](#related-projects).
## Build status
| Linux | [](https://github.com/ntex-rs/ntex/actions/workflows/linux.yml) |
| macOS | [](https://github.com/ntex-rs/ntex/actions/workflows/osx.yml) |
| Windows | [](https://github.com/ntex-rs/ntex/actions/workflows/windows.yml) |
## Usage
Add ntex to your project:
```toml
[dependencies]
ntex = "4"
```
A minimal web server looks like this:
```rust
use ntex::{SharedCfg, web};
#[web::get("/")]
async fn index() -> &'static str {
"Hello world!"
}
#[ntex::main]
async fn main() -> std::io::Result<()> {
web::HttpServer::new(async |_| web::App::new().service(index))
.bind("127.0.0.1:8080", SharedCfg::new("hello-world"))?
.run()
.await
}
```
## Runtime selection
Without an explicit runtime feature, ntex uses its native single-threaded
runtime and automatically selects a platform I/O reactor:
- Linux tries `io_uring` and falls back to polling.
- Other Unix platforms use polling.
- Windows uses IOCP.
Alternative runtimes and native reactors can be selected with Cargo features:
| `tokio` | Tokio local runtime and I/O driver |
| `compio` | Compio runtime and completion-based I/O |
| `neon-polling` | Native runtime with the polling reactor on Unix |
| `neon-uring` | Native runtime with `io_uring` on Linux |
Enable at most one runtime or native-reactor selection feature. For example:
```toml
[dependencies]
ntex = { version = "4", features = ["tokio"] }
```
## Optional features
- `openssl` and `rustls` enable the corresponding TLS integrations.
- `compress` enables HTTP content compression.
- `cookie` enables cookie support.
- `ws` enables WebSocket APIs and is enabled by default.
## Related projects
| [ntex-mqtt](https://github.com/ntex-rs/ntex-mqtt) | Client and server framework for MQTT v5 and v3.1.1 |
| [ntex-amqp](https://github.com/ntex-rs/ntex-amqp) | Client and server framework for AMQP 1.0 |
| [ntex-grpc](https://github.com/ntex-rs/ntex-grpc) | Client and server framework for gRPC |
## Documentation and community
- [Framework guide](https://github.com/ntex-rs/ntex/tree/main/docs/index.md)
- [Web framework documentation](https://ntex.rs)
- [API documentation](https://docs.rs/ntex)
- [Examples](https://github.com/ntex-rs/examples)
- [Release changes](https://github.com/ntex-rs/ntex/blob/main/ntex/CHANGES.md)
- Minimum supported Rust version: 1.97
## License
This project is licensed under either of:
- Apache License, Version 2.0
([LICENSE-APACHE](https://github.com/ntex-rs/ntex/blob/main/LICENSE-APACHE) or
<https://www.apache.org/licenses/LICENSE-2.0>)
- MIT license
([LICENSE-MIT](https://github.com/ntex-rs/ntex/blob/main/LICENSE-MIT) or
<https://opensource.org/licenses/MIT>)