Folkways Developers

Everything to build with Folkways

Docs, the JavaScript SDK, guides, reference and examples. Publish and subscribe to live events with stream, kv and signal; reconnects, replay and token refresh are handled for you.

@folkwaysio/realtime is published on npm for browsers, React Native, Node.js, Deno and Bun.

Install
npm install @folkwaysio/realtime
Connect, subscribe, publish
import { Folkways } from '@folkwaysio/realtime';

const client = await Folkways.connect({
  authUrl: '/api/realtime-token',
});

const chat = client.topic('chat/lobby');
chat.subscribe((msg) => show(msg.data), { from: { last: 20 } });
await chat.publish('message', { text: 'Hello!' });

Start here

Three steps take you from sign-up to a working connection.

  1. 01Set up in the ConsoleA workspace, a segment, a signing key and a topic rule.
  2. 02Add a token endpointSign a short-lived token for each signed-in user.
  3. 03Connect your appInstall the SDK, subscribe and publish.
  4. 04How Folkways worksSegments, tokens, topics and events.

Reference

Examples

SDK source on GitHub

Common questions

What is Folkways?
Folkways is hosted real-time infrastructure. Your apps publish and subscribe to live events on topics, and the JavaScript SDK handles reconnects, replay and token refresh for you. How Folkways works
Which platforms does the JavaScript SDK support?
Browsers, React Native, Node.js, Deno and Bun. Install it with npm install @folkwaysio/realtime. It includes TypeScript declarations. Installation
How do users authenticate?
Your backend signs a short-lived token for each user with @folkwaysio/realtime/server; tokens live at most 15 minutes. The SDK asks your endpoint for a new token about a minute before the current one expires, without dropping subscriptions. Public pages can use a read-only publishable key instead. Identities and tokens
What happens when the connection drops?
The SDK reconnects on its own and queues publishes in the meantime. After reconnecting it resubscribes every topic from the last event you handled, then sends the queued publishes. Connection and reconnects
When should I use stream, kv or signal?
Use stream for ordered events you can replay, such as chat messages or AI tokens. Use kv for state: only the latest value per key is kept, and new subscribers get the current values first. Use signal for short-lived activity such as typing and cursors: signals are not stored, and each sender’s latest one expires after 5 seconds by default. Primitives

SDKs

  • JavaScript / TypeScript
  • Python · not yet available
  • Go · not yet available
  • Java / Kotlin · not yet available
  • Swift · not yet available