Access & Tokens

Who can read and write each field, and signing visitors in with your own backend.

Each field says who may read it and who may write it: anyone, signed-in visitors, or only the owner. The owner is you — the Slash Socket app and the admin API — never a page.

A visitor is signed in when the page sends a token your backend made: an HS256 JWT signed with the server's token secret, carrying who they are. The server checks it on its own, without calling slash.tools or anyone else. Turn tokens on with "auth": { "tokens": true }.

PropTypeDescription
substring, requiredThe visitor's stable id in your system. Map entries and counter limits use it.
expnumber, requiredExpiry, in Unix seconds. Keep it short — the client fetches a fresh token on every reconnect.
namestringShown as the visitor's name (up to 80 characters).
avatarstringAn http(s) image URL.

The secret is SOCKET_TOKEN_SECRET on slash-socket-server. On your Mac, Slash Socket makes one for you: Fields → Visitor tokens → Secret copies it, and Test token copies a signed token you can try from a page for an hour. Keep the secret on your backend only.

app/api/socket-token/route.ts
page.js
  • A token that's wrong or expired closes the connection with code 4001; the client doesn't retry it.
  • With "anonymous": false, pages without a token can't connect at all.
  • read: "signed-in" hides a field from anonymous pages entirely — they don't receive its state or its changes.