Client and server library for bidirectional realtime web apps in Clojure and ClojureScript, with WebSockets and Ajax fallback.
Overview
Sente is a small client-and-server library for building realtime web applications with Clojure on the server and ClojureScript in the browser. It offers a single high-level API for bidirectional messaging so application code does not have to manage the underlying transport directly.
Under the hood it uses core.async together with WebSockets and Ajax. WebSockets provide native client-to-server traffic, emulated ack/reply flows where needed, and native server-to-user push. Ajax complements that with emulated bidirectional patterns and native request-response semantics when sockets are unavailable. The design includes automatic keep-alive, buffering, protocol selection, reconnects, and event batching for low bandwidth.
Applications can send Clojure values using fast binary serialization, track users connected across multiple clients or devices, and query which protocols each connection uses. Security follows the standard Ring model, so teams can apply their own authentication, HTTPS, and CSRF policies and plug into diverse web servers and transmission formats.
The API is intentionally small compared with lower-level socket libraries, which suits chat, live dashboards, and other apps that need reliable push from the server without writing WebSocket plumbing by hand.
Key features
- WebSockets with Ajax fallback
- Unified bidirectional API
- Auto reconnect and keep-alive
- Binary Clojure value serialization
- Multi-device connection tracking
- Ring-compatible security model
- Event batching for bandwidth
- Ack and reply over both transports
Use cases
- Realtime Clojure web applications
- Live server push to browsers
- Apps needing socket fallback to Ajax
- Multi-tab and multi-device sessions
- Ring-based authenticated comms