Quick Start
Three ways to run an HTTP/3 server — pick the one that fits your stack.
Option 1: Python — Serve a FastAPI app
# app.py
from fastapi import FastAPI
import nhttp3
app = FastAPI()
@app.get("/")
async def root():
return {"message": "Hello from HTTP/3!"}
@app.get("/health")
async def health():
return {"status": "ok", "protocol": "h3"}
# One line — replaces uvicorn.run(app)
nhttp3.serve(app, port=4433, certfile="cert.pem", keyfile="key.pem")
# Run it
python app.py
# Test it
curl --http3 https://localhost:4433/ -k
curl --http3 https://localhost:4433/health -k
Option 2: CLI — Serve any ASGI app
# Serve an existing app without modifying code
nhttp3 run myapp:app --port 4433 --certfile cert.pem --keyfile key.pem
# Equivalent to:
# uvicorn myapp:app --port 8000
Option 3: Rust — Low-level QUIC
use nhttp3::quic::endpoint::Endpoint;
use nhttp3::quic::config::Config;
let config = Config::default();
let endpoint = Endpoint::bind(
"0.0.0.0:4433".parse()?,
config,
Some(server_tls),
None,
).await?;
// Accept connections
let conn = endpoint.accept().await.unwrap();
conn.established().await;
// Open a stream
let (send, recv) = conn.open_bidi_stream().unwrap();
send.write_all(b"hello").await?;
What Just Happened?
| Step | What nhttp3 did |
|---|---|
| 1 | Bound a UDP socket on port 4433 |
| 2 | Started listening for QUIC Initial packets |
| 3 | Client sent a QUIC Initial with TLS ClientHello inside a CRYPTO frame |
| 4 | Server completed TLS 1.3 handshake in 1-RTT (vs 2-RTT for TCP+TLS) |
| 5 | Client opened a bidirectional QUIC stream |
| 6 | HTTP/3 request/response flowed over that stream with QPACK-compressed headers |
Key Difference from HTTP/2
Each request uses its own QUIC stream. If one response is slow, it doesn't block others. This is the "no head-of-line blocking" advantage that HTTP/3 provides over HTTP/2's shared TCP connection.
Next Steps
- FastAPI Guide — Full migration guide with streaming, middleware
- SGLang / LLM Guide — Stream LLM tokens over HTTP/3
- curl Guide — Test your server from the command line
- Browser Guide — Fetch API, WebTransport, streaming
- Core Concepts — Understand QUIC, streams, and flow control