folkwaysDocs
Get started

Public apps without a backend

Connect a public, read-only page, such as a live scoreboard, with a publishable key instead of a token endpoint.

A page that only shows public data, such as a scoreboard, a status page or a live map, doesn't need a backend or a sign-in. It uses a publishable key, which the Realtime API trades for an anonymous, read-only token. The key ships inside your page, so everything it can read is public.

Set up the segment

In the Console, follow Set up in the Console up to the topic rule (you can skip the signing key). Then in the segment's Settings, turn on Allow anonymous connections.

Add a publishable key

On Publishable keys, choose Add key, name it, and set What it may read, e.g. scores/>. Copy the key.

Connect and subscribe

scoreboard.ts
TypeScript
import { Folkways } from '@folkwaysio/realtime';

declare function showScore(score: unknown): void;

const client = new Folkways.Realtime({
  url: 'https://realtime.folkways.net',
  publishableKey: 'YOUR_PUBLISHABLE_KEY',
});
await client.connect();

client.topic('scores/match-7').subscribe((msg) => showScore(msg.data));

Viewers can only read: publishable keys never grant publishing. Something still has to publish the data, usually your own server over HTTP; see Publish from your backend and the live dashboard example.

See Publishable keys for pausing, revoking and rotating keys.

On this page