# nxtquic-api
[](https://crates.io/crates/nxtquic-api)
[](https://docs.rs/nxtquic-api)
[](https://github.com/nxtstream/nxtquic/blob/main/LICENSE.md)
[](Cargo.toml)
**High-level async API for NxtQuic.**
`nxtquic-api` is the ergonomic async/await layer of the [NxtQuic](https://crates.io/crates/nxtquic) workspace. It wraps the I/O-free `nxtquic-proto` state machine and the `nxtquic-udp` socket layer into a beautiful, Tokio-compatible API with familiar `AsyncRead` / `AsyncWrite` stream interfaces.
## Features
- **`Endpoint`** — bind a QUIC UDP endpoint as client or server
- **`Connection`** — manage a single QUIC connection with full lifecycle control
- **`SendStream` / `RecvStream`** — `AsyncWrite` / `AsyncRead`-compatible bidirectional and unidirectional streams
- **Unreliable datagrams** — send/receive RFC 9221 datagrams through the same connection
- **Tokio runtime integration** — optional `tokio-runtime` feature (enabled by default)
- **TLS via `rustls`** — secure connections with zero-copy TLS session tickets
## Feature flags
| `tokio-runtime` | ✅ yes | Enable the Tokio-based async driver |
## Quick Start
```toml
[dependencies]
nxtquic-api = "0.1.2"
tokio = { version = "1", features = ["full"] }
```
```rust
use nxtquic_api::{Endpoint, ServerConfig};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let endpoint = Endpoint::server(server_config, "0.0.0.0:4433".parse()?).await?;
while let Some(incoming) = endpoint.accept().await {
let conn = incoming.accept().await?;
tokio::spawn(handle_connection(conn));
}
Ok(())
}
```
For the full workspace including HTTP/3, WebTransport, and simulation, use the top-level [`nxtquic`](https://crates.io/crates/nxtquic) crate.
## Part of the NxtQuic workspace
| [`nxtquic`](https://crates.io/crates/nxtquic) | Top-level re-export, async API |
| [`nxtquic-proto`](https://crates.io/crates/nxtquic-proto) | Core state machine |
| [`nxtquic-crypto`](https://crates.io/crates/nxtquic-crypto) | Pluggable crypto backends |
| [`nxtquic-udp`](https://crates.io/crates/nxtquic-udp) | Platform-optimized UDP I/O |
| **`nxtquic-api`** | **Tokio async/await API (this crate)** |
| [`nxtquic-h3`](https://crates.io/crates/nxtquic-h3) | HTTP/3 + QPACK |
| [`nxtquic-sim`](https://crates.io/crates/nxtquic-sim) | Deterministic network simulator |
| [`nxtquic-qlog`](https://crates.io/crates/nxtquic-qlog) | qlog structured logging |
## License
Licensed under either of [MIT](https://github.com/nxtstream/nxtquic/blob/main/LICENSE.md) or Apache-2.0 at your option.