Elegant HTTP networking library for Swift, built on URLSession, with chainable requests, encoding, uploads, downloads and response validation.
apple/swift-nio
Cross-platform, non-blocking event-driven networking framework in Swift for building high-performance protocol servers and clients, similar to Netty.
- Stars
- 8,538
- Forks
- 816
- Open issues
- 307
- Last commit
- 3 days ago
What is it?
SwiftNIO is a low-level networking framework for Swift that uses non-blocking I/O and event loops to build protocol servers and clients. Instead of dedicating a thread to each connection, it multiplexes many connections across a small number of event loops, which suits servers that hold large numbers of relatively idle connections. It is described as a Swift counterpart to Netty.
The framework provides the core building blocks: EventLoopGroup and EventLoop for I/O dispatch, Channel and ChannelPipeline with ChannelHandlers for processing data, ByteBuffer for byte handling, and futures and promises for asynchronous results. Modules cover POSIX I/O (NIOPosix), testing helpers (NIOEmbedded, NIOTestUtils), and low-level HTTP/1.1 and WebSocket protocol implementations. TLS, HTTP/2, SSH and other protocols live in companion repositories.
SwiftNIO is aimed at framework authors and teams that need fine control over networking performance, rather than end-user web development. Higher-level libraries such as AsyncHTTPClient, gRPC Swift and PostgresNIO are built on top of it.
Key features
- 01Non-blocking I/O built on event loops, using kqueue or epoll depending on the platform.
- 02Channel and ChannelPipeline model for composing reusable protocol handlers.
- 03Low-level HTTP/1.1 and WebSocket protocol implementations.
- 04ByteBuffer for efficient copy-on-write byte handling.
- 05EmbeddedChannel and EmbeddedEventLoop for testing protocol code without real networking.
- 06Supports macOS and Linux, with experimental OpenBSD support.
Use cases
- Building a custom protocol server or client in Swift that must handle many concurrent connections.
- Developing a higher-level Swift networking library or web framework on top of a non-blocking core.
- Writing performance-sensitive services where thread-per-connection models are too costly.
- Unit testing protocol handlers in isolation using the embedded channel.
Quick start
- 1
Add SwiftNIO to your Package.swift dependencies using a version range such as from: "2.0.0"
- 2
Add the NIO product to your target and import NIO in your Swift code
Things to know
- It is a low-level networking toolkit, not a high-level web framework, so it requires good understanding of its event-loop and channel model.
- Recent releases require a newer Swift toolchain, for example Swift 6.1 for version 2.98.0 and later.
- SwiftNIO 1 is end of life and receives no new features.
Topics
FAQ
- What is swift-nio?
- Cross-platform, non-blocking event-driven networking framework in Swift for building high-performance protocol servers and clients, similar to Netty. SwiftNIO is a low-level networking framework for Swift that uses non-blocking I/O and event loops to build protocol servers and clients. Instead of dedicating a thread to each connection, it multiplexes many connections across a small number of event loops, which suits servers that hold large numbers of relatively idle connections. It is described as a Swift counterpart to Netty.
- Is swift-nio free to use? What license does it have?
- swift-nio is open source under the Apache-2.0 license. Check the license terms before using it in commercial products.
- Is swift-nio still maintained?
- Actively maintained. The last commit to swift-nio was on Oct 19, 2026.
- What can I use swift-nio for?
- Building a custom protocol server or client in Swift that must handle many concurrent connections. Developing a higher-level Swift networking library or web framework on top of a non-blocking core. Writing performance-sensitive services where thread-per-connection models are too costly. Unit testing protocol handlers in isolation using the embedded channel.
- How do I install swift-nio?
- Add SwiftNIO to your Package.swift dependencies using a version range such as from: "2.0.0" Add the NIO product to your target and import NIO in your Swift code
- Where can I get swift-nio?
- The source code and installation instructions are on GitHub: https://github.com/apple/swift-nio
Summary generated by AI from the project's README. GitHub stats refresh daily.
Related projects
Socket.IO is a library for real-time, bidirectional, low-latency event-based communication between clients and servers.
An HTTP client for the JVM, Android, and GraalVM that reuses connections, supports HTTP/2, and caches responses by default.
A high-performance, minimalist web framework for Go, built on the standard net/http package.
A fast, Flask-style C++ microframework for building HTTP and WebSocket web services, header-only and easy to use.
An interactive, TLS-capable intercepting HTTP proxy with console, command-line and web interfaces for inspecting HTTP/1, HTTP/2 and WebSocket traffic.