Skip to content
loco
v1.0
★ 6.9k Get started

Add websockets / realtime

Goal: add realtime, bidirectional communication (chat, live updates, notifications) to a Loco app.

Loco doesn’t ship a built-in websocket abstraction. Because a Loco app compiles down to a real axum::Router<AppContext> (see Coming from Axum), any Axum-compatible websocket layer mounts onto it the same way it would onto a hand-rolled Axum app — there’s no Loco-specific API to learn for this, and no Loco-specific limitation either.

Chat room example

For a worked example using socketioxide, see the loco-rs/chat-rooms reference app. It shows a full chat-room implementation wired into a Loco router.

If you need something other than socketioxide, look for any crate that integrates with axum::Router (raw axum::extract::ws, socketioxide, etc.) and mount it the same way you’d add a controller — as routes on the app’s Router.