jvdvleuten

jvdvleuten

PhoenixNectar - Swift 6 client for Phoenix Channels

PhoenixNectar is a Swift client for Phoenix Channels, built from the ground up for Swift 6 strict concurrency.

It builds on the great work of SwiftPhoenixClient by David Stump and Daniel Rees, which has been the go-to Swift client for years. PhoenixNectar takes a different approach by embracing Swift’s modern concurrency model (actors, async/await, and AsyncStream) rather than the JS-style callback API.

What it looks like

import PhoenixNectar

struct ChatMessage: Codable, Sendable {
   let body: String
}

let client = try Socket(endpoint: "wss://api.example.com/socket")
try await client.connect()

let channel = try await client.joinChannel("room:lobby")

// Subscribe with AsyncStream
let posted = Event<ChatMessage>("message:posted")

for try await message in await channel.subscribe(to: posted) {
   print(message.body)
}

// Typed push with reply
let send = Push<ChatMessage, ChatMessage>("message:send")
let reply = try await channel.push(send, payload: ChatMessage(body: "hello"))
print(reply.body)

Features

  • Swift 6 strict concurrency — actor-owned runtime, no @unchecked Sendable workarounds
  • Push<Request, Response> and Event<T> for compile-time payload type safety
  • Auto reconnect, heartbeat, and channel rejoin
  • Auth token providers that re-evaluate on each reconnect
  • Connection state observation via AsyncStream
  • Binary channel support
  • iOS 16+, macOS 15+, tvOS 18+, watchOS 11+

Feedback welcome, especially from anyone running Phoenix Channels with iOS/macOS clients.

A demo project (demo iOS project with chat and image upload) and E2E tests are provided as well.

https://github.com/jvdvleuten/PhoenixNectar

Most Liked

_pk

_pk

This is awesome to see! I’m quite interested as I make heavy use of Phoenix Channels in iOS apps, and have been thinking of working up something like this.

SwiftPhoenixClient has been great, I’m grateful for it and have made a few contributions. But it would need a ton of work to adopt strict concurrency and I agree that starting from scratch is the better move.

I’ll try dropping this into a project and send some detailed feedback soon.

Where Next?

Popular in Announcing Top

OvermindDL1
I created a new library (rather I pulled out a couple files from my big project), it manages an operating system PID file for the BEAM. ...
New
aesmail
Hello guys, I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
New
kevinlang
Hey all, We have made an Ecto3 Adapter for SQLite3, ecto_sqlite3! We have successfully on-boarded the full suite of integration tests (...
New
fuelen
Hey folks! Want to present a toolkit for writing command-line user interfaces. It provides a convenient interface for colorizing text...
New
trisolaran
Hi! :waving_hand: I would like to present LiveSelect, a little library that I wrote to easily add a dynamic selection input to your LV f...
198 11220 107
New
Flo0807
Hello everyone! I am excited to share our heart project Backpex with you. After building several Phoenix applications, we realized that...
New
markmark206
simple_feature_flags is a tiny package that lets you turn features on or off based on which environment (e.g. localhost, staging, product...
New

Other popular topics Top

rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1144 54921 245
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
TunkShif
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
274 42533 114
New

We're in Beta

About us Mission Statement