horus_js

Horus is the browser client for Thoth,
Maat's Pusher-compatible WebSocket server. horus_client covers Dart and
Flutter; Horus JS covers the page — one dependency-free file, no build step.
Application.configure(...)
.withExtensions([horusJsExtension])
.create();
Install
A server-rendered Maat application needs no npm at all — add horus_js to
pubspec.yaml, wire .withExtensions([horusJsExtension]) in
bootstrap/app.dart, and run the command:
maat horus:install # publishes public/js/horus.js
<script src="{{ asset('js/horus.js') }}"></script>
<script>
const horus = new Horus({ key: '...', host: 'localhost', port: 6001 });
horus.channel('news').on('PostPublished', (post) => render(post));
</script>
A decoupled front end with its own bundler installs the same client from npm instead, versioned in lockstep with this package:
npm install @gaitco/horus
import Horus from '@gaitco/horus';
const horus = new Horus({ key: '...', host: 'localhost', port: 6001 });
What it does
- Subscribes to public, private, and presence channels, adding the
private-/presence-prefix for you. - Presence channels track the member list (
here,joining,leaving). channel.whisper(event, data)sends a client event to the other subscribers, gated server-side onclient_events.- Reconnects on its own with exponential backoff and jitter, re-authorizing every private and presence channel with a fresh signature.
horus.fetch(url, init)isfetchwith this connection's socket id attached, so a request handled withbroadcast(...).toOthers(request).send()doesn't apply its own broadcast twice.
Full guide: docs/realtime-browser.md.
Libraries
- horus_js
- The Horus browser client for Thoth.