ntex framework guide
ntex is a Rust framework for building asynchronous network services. You can use it for an HTTP API, a web application, or a server that speaks your own protocol. Its web framework handles routing, request extraction, middleware, and responses, while the lower-level crates let you work directly with connections and messages. You can start with the web APIs without learning all of those layers first.
This guide is for Rust developers who want to build something with ntex and
understand how its pieces fit together. It assumes you know Rust’s basic
types, traits, and async/await; it does not assume experience with ntex.
Examples show the public APIs, and the linked API reference gives the full
type signatures and options when you need them.
The common building block is a service: a component that accepts a request and produces a response or an error asynchronously. A request might be an HTTP request, a decoded protocol message, or a connection. Pipelines give services a shared context for state, readiness, calls, and shutdown. That makes the same composition model useful for a small handler and for a stack of protocol services. You will meet services gradually, rather than needing to implement one before your first web route.
ntex also separates protocol code from the runtime that drives it. You can choose Tokio, Compio, or ntex’s native runtime without rewriting your web handlers. The I/O layer provides buffered connections and filters, so concerns such as TLS can sit below your protocol implementation. These layers matter most when you need a custom protocol or control over connection behavior; ordinary web applications usually let the HTTP server assemble them.
Servers run applications on workers. Each worker can initialize its own state, such as a client handle or cache, and that state can use single-threaded shared types. When data must be shared across workers, you choose a thread-safe shared handle instead. The distinction helps you decide where initialization belongs and what a state clone should share, rather than treating every application value as process-wide.
Start with Getting Started to run a server, add a few routes, and write a test. If you are building a web application, continue with chapter 8, beginning with Routing and Handlers. You can return to the service and server chapters when you need more control over startup, state, or middleware.
If you are writing a protocol, begin with Service Model, Service Pipelines, and the I/O Abstraction Layer. The chapters are also useful independently: follow the links for the layer you are working on, or use the cookbook for a focused example. The API reference, LLM documentation, and migration guide are listed below the chapters.
- Getting Started
- Service Model
- Service Pipelines
- Service State
- Runtime
- Server
- Worker and Request State
- I/O Abstraction Layer
- Web Application Framework
- Testing
- Integrations
- Securing Connections with TLS
- Byte Buffers
- Timers and Time Utilities
- Cookbook
API reference
LLM documentation
- llms.txt: rules and templates for generated code
- llms-full.txt: this guide as a single text file