/volcano:volcano-realtimefrom volcano
Use for realtime or live updates in Volcano apps, including collaborative boards, chat, presence and online users, live polls and results, leaderboards, Postgres changes, broadcast, WebSockets, and connection lifecycle.
Ships in volcano. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Implement live updates with deterministic realtime lifecycle handling. This skill is self-contained: connection lifecycle, all three channel types (postgres / broadcast / presence), token refresh, and cleanup are embedded. Live progress from a durable workflow uses durable.messages.subscribe (see "Durable workflow progress").
realtime: { enabled: true } in volcano-config.yaml, then config deploy (off by default; see "Enable realtime").VolcanoRealtime with apiUrl, anonKey, and accessToken (or getToken).connect(), then create channels with the right type.subscribe().subscribe() with unsubscribe() on teardown; pair connect() with disconnect().centrifuge is required.ws only for Node.js server-side realtime usage. The SDK uses the browser's native WebSocket automatically and ws automatically in Node.js — provide a custom implementation only for advanced cases (see "Custom WebSocket Implementation" below).Realtime is disabled by default for every project — local and cloud alike
(enabled: false). Until you enable it, every connection is rejected with
realtime disabled for project. Declare it in volcano-config.yaml and deploy:
# volcano-config.yaml
version: 1
realtime:
enabled: true # required — off by default
# broadcast_enabled: true # optional, default true
# presence_enabled: true # optional, default true
# postgres_changes_enabled: true # optional, default true
Apply with volcano config deploy (local) / volcano cloud config deploy
(cloud). This is the only realtime setup that isn't app code — the same
config governs both environments, so a realtime app verified locally deploys to
the cloud unchanged. Everything else (apiUrl/anonKey/accessToken, channels,
handlers) is identical across environments. In local mode, apiUrl is
http://localhost:8000 with the local anon key from volcano status, and you
can sign in as the shipped default user ([email protected]) to get an
accessToken without building a signup flow first.
import { VolcanoRealtime } from '@volcano.dev/sdk/realtime';
const realtime = new VolcanoRealtime({
apiUrl: 'https://api.yourproject.volcano.dev',
anonKey: 'your-anon-key',
accessToken: volcano.accessToken, // JWT from auth session
});
await realtime.connect();
Browser WebSocket connections include an Origin header. When CORS is enabled for your project, that origin must be listed in the project's auth CORS allowed origins or the WebSocket upgrade is rejected before authentication completes — connect fails silently from the client's point of view.
Add your app's origin (for local development, e.g. http://localhost:3000) under auth.cors.allowed_origins:
auth:
cors:
allowed_origins:
- https://app.example.com
- http://localhost:3000
The list is the whole list: deploying a manifest replaces the target's stored origins with it. Edit the copy that belongs to the target you are changing:
The project's volcano-config.yaml already declares auth.cors: add the origin there. volcano deploy and volcano cloud deploy apply that file, so its list must hold every origin each target serves; an origin added there reaches the cloud project too.
Otherwise: pull the target's current settings into a separate file, add the origin, and deploy that file back to the same target:
volcano config pull -f local-config.yaml
# add the origin under auth.cors.allowed_origins in local-config.yaml
volcano config deploy -f local-config.yaml
For a cloud project, use volcano cloud config pull and volcano cloud config deploy the same way.
Never deploy a manifest pulled from one target to another: its origin list would replace the other target's. config pull does not overwrite an existing file unless you pass --force.
Server-side Node.js connections usually do not send an Origin header and are not blocked by browser CORS checks.
Symptoms of a CORS misconfiguration:
realtime.connect() resolves but onConnect never fires.onError fires with an opaque WebSocket error (no message).Failed or (blocked).Fix: add the origin to the project's auth CORS allowed origins, then reconnect.
Most applications do not need this. The SDK uses the browser's native WebSocket in browsers and ws in Node.js. For Node.js tests or advanced server-side clients that need to inject custom headers (e.g., a fixed Origin header to satisfy CORS in a non-browser context), pass a webSocket constructor:
import WebSocket from 'ws';
class OriginWebSocket extends WebSocket {
constructor(address, protocols, options = {}) {
super(address, protocols, {
...options,
headers: {
...options.headers,
Origin: 'https://app.example.com',
},
});
}
}
const realtime = new VolcanoRealtime({
apiUrl: 'https://api.yourproject.volcano.dev',
anonKey: 'your-anon-key',
accessToken: volcano.accessToken,
webSocket: OriginWebSocket,
});
The webSocket config takes any WebSocket-compatible constructor — useful for tests that mock the transport, or for environments that need TLS client certs / proxy support beyond what ws exposes by default.
realtime.onConnect((ctx) => {
// ctx.client, ctx.latency
});
realtime.onDisconnect((ctx) => {
// ctx.reason, ctx.reconnect (auto-reconnect with exponential backoff)
});
realtime.onError((ctx) => {
// ctx.message
});
const channel = realtime.channel('my-changes', { type: 'postgres' });
The signature is channel.onPostgresChanges(eventType, schema, table, callback). The schema argument is the Postgres schema name — typically 'public' for application tables.
channel.onPostgresChanges('*', 'public', 'posts', (change) => {
// change.type: 'INSERT' | 'UPDATE' | 'DELETE'
// change.table, change.schema, change.timestamp
// INSERT: change.record
// UPDATE: change.record, change.old_record, change.columns
// DELETE: change.old_record
});
await channel.subscribe();
channel.onPostgresChanges('INSERT', 'public', 'messages', (c) => addMessage(c.record));
channel.onPostgresChanges('UPDATE', 'public', 'posts', (c) => updatePost(c.record));
channel.onPostgresChanges('DELETE', 'public', 'posts', (c) => removePost(c.old_record.id));
const channel = realtime.channel('app-changes', { type: 'postgres' });
channel.onPostgresChanges('*', 'public', 'posts', handlePostChange);
channel.onPostgresChanges('*', 'public', 'comments', handleCommentChange);
channel.onPostgresChanges('*', 'public', 'reactions', handleReactionChange);
await channel.subscribe();
Each user only receives events for rows their RLS policy allows them to see. Same channel, different deliveries per user.
Messages aren't persisted; only currently subscribed clients receive them.
const channel = realtime.channel('notifications', { type: 'broadcast' });
channel.on('notification', (data) => {
showNotification(data.title, data.message);
});
channel.on('*', (data, ctx) => {
// catch-all listener
});
await channel.subscribe();
await channel.send({
type: 'notification',
title: 'New Feature!',
message: 'Check out our latest update',
});
const channel = realtime.channel('chat-room-123', { type: 'broadcast' });
channel.on('typing', (data) => {
if (data.user_id !== currentUser.id) showTyping(data.user_id);
});
channel.on('stopped_typing', (data) => hideTyping(data.user_id));
await channel.subscribe();
let typingTimer: any;
function onInput() {
channel.send({ type: 'typing', user_id: currentUser.id });
clearTimeout(typingTimer);
typingTimer = setTimeout(() => {
channel.send({ type: 'stopped_typing', user_id: currentUser.id });
}, 2000);
}
const channel = realtime.channel('lobby', { type: 'presence' });
await channel.subscribe();
await channel.track({
user_id: currentUser.id,
username: currentUser.name,
status: 'online',
avatar: currentUser.avatar_url,
});
channel.onPresenceSync((state) => {
// state: { [clientId]: userData }
const onlineUsers = Object.entries(state).map(([clientId, data]) => ({ clientId, ...data }));
updateOnlineUsersList(onlineUsers);
});
const state = channel.getPresenceState();
for (const [clientId, userData] of Object.entries(state)) {
// ...
}
await channel.track({
user_id: currentUser.id,
username: currentUser.name,
status: 'away',
last_seen: new Date().toISOString(),
});
To show what a durable execution publishes with ctx.publish, use
volcano.durable.messages.subscribe on a connected client. Never subscribe to
a raw durable: channel; the SDK resolves it and catches up from the message
list so nothing published before the subscribe is missed.
const { data: subscription, error } = await volcano.durable.messages.subscribe(
{ functionName: 'publish-post', executionId: execution.id, clientToken: execution.client_token },
(message) => showProgress(message.data),
{ realtime },
);
// Refused without a user session, with Realtime off, or past visibility.
if (error) throw error;
// On teardown
await subscription?.unsubscribe();
Realtime must be enabled for the project. A publish counts as one Realtime
message plus one for each subscriber it reaches, and again if it reruns after
a crash; with no subscribers it costs nothing. Clients cannot publish on that channel; they send with
durable.messages.send. The connection needs a user session, so sign the
browser in first. For visitors without an account, enable guest sign-in as
described in Anonymous Users, then call
signInAnonymously(). The function must be
authenticated, which admits both. The bare anon key never connects: with a
public function it can only list and send. Anonymous sign-in takes only
the anon key, so either way anyone can start executions; validate their
input. See volcano-durable for who can reach an execution.
channel.unsubscribe();
realtime.removeChannel('my-channel', 'postgres');
realtime.removeAllChannels();
realtime.isConnected(); // boolean
realtime.disconnect();
accessToken vs getTokenUse accessToken for short-lived UI sessions where the page lifecycle is bounded by JWT expiry (~1 hour). Use getToken for long-lived clients — background tabs, desktop/native apps, edge workers, server-side polling — so the realtime client refreshes the JWT seamlessly without dropping the connection.
const realtime = new VolcanoRealtime({
apiUrl: 'https://api.example.com',
anonKey: 'anon-key',
getToken: async () => {
const { session } = await volcano.auth.refreshSession();
return session.access_token;
},
});
const volcano = new VolcanoAuth({ ... });
volcano.database('your_database_name');
const realtime = new VolcanoRealtime({
apiUrl: 'https://api.example.com',
anonKey: 'anon-key',
accessToken: volcano.accessToken,
volcanoClient: volcano, // enables auto-fetch lightweight mode
databaseName: 'your_database_name', // optional if database(...) was called
});
import {
VolcanoRealtime,
RealtimeChannel,
PostgresChange,
PresenceState,
ConnectContext,
DisconnectContext,
ErrorContext,
} from '@volcano.dev/sdk/realtime';
// Load initial data
const { data: posts } = await volcano
.from('posts')
.select('*')
.order('created_at', { ascending: false })
.limit(50);
setPosts(posts ?? []);
// Subscribe for updates
channel.onPostgresChanges('INSERT', 'public', 'posts', (c) => {
setPosts((cur) => [c.record, ...cur]);
});
channel.onPostgresChanges('UPDATE', 'public', 'posts', (c) => {
setPosts((cur) => cur.map((p) => (p.id === c.record.id ? c.record : p)));
});
channel.onPostgresChanges('DELETE', 'public', 'posts', (c) => {
setPosts((cur) => cur.filter((p) => p.id !== c.old_record.id));
});
await channel.subscribe();
useEffect(() => {
const realtime = new VolcanoRealtime({ /* ... */ });
realtime.connect();
const channel = realtime.channel('updates', { type: 'postgres' });
channel.onPostgresChanges('*', 'public', 'posts', handleChange);
channel.subscribe();
return () => {
channel.unsubscribe();
realtime.disconnect();
};
}, []);
onConnect so missed events are reconciled.getToken for long-lived sessions instead of a static accessToken.realtime.onError((ctx) => {
showConnectionError(ctx.message);
});
try {
await channel.subscribe();
} catch (error) {
console.error('Subscription failed:', error.message);
}
Connection rejected (connect times out or never accepts):
realtime disabled for project — realtime is off for this project; add
realtime: { enabled: true } to volcano-config.yaml and config deploy
(see "Enable realtime"). Off by default in local and cloud.invalid apikey / anon key not found — wrong anonKey for the target
project (or the wrong apiUrl).accessToken (signIn first, or signInAnonymously for a visitor without an
account once guest sign-in is enabled). The anon key alone never connects, in local or cloud.realtime: { enabled: true } in volcano-config.yaml, config deployd) — off by default.connect() is paired with disconnect(); subscribe() is paired with unsubscribe().subscribe().centrifuge is present; ws only when Node-side realtime is used.What SKILL.md sets; muted values are Claude Code's defaults
18 skills in this plugin
/install-volcanoInstall, upgrade, or set up the Volcano CLI. Use this whenever a task needs the volcano CLI and `which volcano` hasn't been confirmed yet, even if the user never says "install" (e.g. "build me a todo API using volcano")./volcano-authUse for Volcano authentication and identity work including user accounts, email or password sign-up and sign-in, OAuth, sessions, anonymous users, password recovery, and private or per-user data./volcano-databaseUse whenever a Volcano app stores or persists data, including CRUD, records, per-user data, migrations, RLS, todos, chat messages, polls, analytics, counters, click tracking, CMS content, feature flags, and leaderboards.npx claudepluginhub kong/volcano-agentic-plugins --plugin volcanoOther plugins' skills for the same job