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

josevalim
Yes, yet another parser combinator library! Most of the parser combinators in the ecosystem are either compile-time, often using AST tra...
159 19834 141
New
wfgilman
I’ve cleaned up and open sourced three financial libraries I was using for my company. They are bindings for the APIs of these three comp...
New
mathieuprog
Hello :waving_hand: Allow me to introduce you to Tz, an alternative time zone database support to Tzdata. Why another library? First a...
New
wojtekmach
Hey everyone! Req is an HTTP client for Elixir that I’ve been working on for quite some time. There is already a lot of HTTP clients out...
New
type1fool
WebAuthnLiveComponent WebAuthnComponents See this post about renaming the package. Passwordless authentication for Phoenix LiveView app...
New
zachdaniel
Ash Framework What is Ash? Ash Framework is a declarative, resource-oriented application development framework for Elixir. A resource can...
New
restlessronin
The repo is at GitHub - cyberchitta/openai_ex: Community maintained Elixir library for OpenAI API · GitHub. Docs are at OpenaiEx User Gu...
152 10719 134
New

Other popular topics Top

electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
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
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 44139 214
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