Swiftpack.co -  tesseract-one/WebSocket.swift as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
Cross-platform WebSocket client implementation based on Swift NIO
.package(url: "https://github.com/tesseract-one/WebSocket.swift.git", from: "0.0.8")


🐧 linux: ready GitHub license Build Status GitHub release SPM compatible CocoaPods version Platform OS X | iOS | tvOS | watchOS | Linux

Cross-platform WebSocket client implementation based on Swift NIO


We have good WebSocket libraries for Apple platforms, but we need it on Linux too. This library based on Apple Swift NIO framework, which allows it to be cross-platform.

Getting started


Package Manager

Add the following dependency to your Package.swift:

.package(url: "https://github.com/tesseract-one/WebSocket.swift.git", from: "0.0.8")

Run swift build and build your app.


Add the following to your Podfile:

pod 'TesseractWebSocket.swift'

Then run pod install


Echo Connection

import Foundation
import WebSocket

let socket = WebSocket()

socket.onConnected = { ws in

socket.onData = { data, ws in
  print("Received", data)
  assert(data.text! == "hello")

socket.connect(url: URL(string: "wss://echo.websocket.org")!)

WARNING! You should always disconnect WebSocket. It will leak otherwise! And will leak thread too!



WebSocket.swift is available under the Apache 2.0 license. See the LICENSE file for more information.


Stars: 3
Last commit: 3 weeks ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Submit a free job ad (while I'm testing this). The analytics numbers for this website are here.

Release Notes

Fixed warnings in the new NIO versions
3 weeks ago

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics