Console
Publishable keys
Let a public, read-only app connect without a backend, with a key it trades for anonymous tokens.
A publishable key lets an app with no backend, such as a public scoreboard or a status page, connect to Folkways. The app trades the key for an anonymous, read-only token and connects with that. The key ships inside your app, so everything it grants is public.
| A publishable key can | It can't |
|---|---|
Grant subscribe (and history) on the topics you choose | Publish, set values or send signals |
| Issue anonymous tokens, up to 15 minutes each | Name a user |
If users sign in to your app, use a signing key and tokens from your backend instead.
Create one
- In the segment's Settings, turn on Allow anonymous connections. Without it, the key's tokens are refused.
- On Publishable keys, choose Add key.
- Name it, e.g. "Public scoreboard", and set What it may read: topic patterns such as
scores/>. - Optionally set an expiry date. After it, the key stops working and no token it issued outlives it.
- Save and copy the key into your app.
Pause, resume and revoke
| Action | Effect |
|---|---|
| Pause | New exchanges are refused with Suspended, and connections using the key's tokens close within about a minute. Resume undoes it |
| Revoke | The key stops working for good (AuthInvalid), and its connections close within about a minute |
To rotate a key: create a new one, ship your app with it, then revoke the old one.
Use it
const client = new Folkways.Realtime({ url: 'https://realtime.folkways.net', publishableKey: PUBLISHABLE_KEY });