Option 1: React / React Native SDK (Recommended)
If your application uses React or React Native, the SDK is the recommended integration path. It wraps the REST API in a set of hooks and context providers that do the heavy lifting:- Token lifecycle — Access tokens are requested, stored, and refreshed automatically. You never manually manage auth headers.
- Real-time — The chat system connects via WebSocket automatically when
ChatProvideris mounted. Message delivery, read state, and typing indicators are handled for you. - Optimistic state — Actions like sending a message or toggling a reaction update local state immediately and sync with the server in the background.
- Typed interfaces — Every object your hooks return is typed against the interfaces in
@sublay/core. You get full autocomplete and type safety across entities, users, conversations, comments, and more. - Context providers — Features like the entity subtree, comment section, conversation, and space are scoped via React context providers, so any component in the subtree can access the full feature state with a single hook call.
React (Web)
Install
@sublay/react-js. Works with Next.js, Vite, Create React App, or any React web setup.React Native / Expo
Install
@sublay/react-native (or @sublay/expo for Expo-managed workflows).SDK Package Reference
Option 2: Raw REST API
If your application does not use React, or you need to call Sublay from a server-side context, the REST API is available directly. All endpoints are under/v8/:projectId/. Every request that requires a user identity must include a valid access token in the Authorization: Bearer <token> header.
Use cases for direct API access:
- Vue, Angular, Svelte, or other non-React frameworks
- Server-to-server operations (e.g., creating entities on behalf of users, webhook handlers, scheduled jobs)
- Custom SDKs or thin client wrappers
- Testing or exploration with tools like Postman or curl
Service API Key (Recommended for Server-to-Server)
For server-to-server calls, using a service API key is almost always the right approach rather than managing individual user access tokens. A service API key is generated once from the project dashboard and stored securely on your server. When included in a request, it grants elevated access to the API:- No user token required — the service key bypasses user authentication entirely. You do not need to sign in as a user or manage token refresh on the server.
- Act on behalf of any user — a service key names the user it acts as in
actingUserId(in the query string on a GET or DELETE, in the body on a POST, PATCH or PUT, like every other field), and the request runs as that user. Some endpoints require it, some reads take it optionally to return that user’s view, edits and deletes of a user’s own content require it to name the author, and a few always act as the app and refuse it.userIdonly names a user the request is about, such as a target or a filter. See Acting as a user. - Some endpoints need the user’s own token — changing or setting a password, self-service account deletion, linking or listing OAuth identities, and registering or removing a push device refuse a service key (
403 <resource>/user-token-required). - The owner acts — editing, deleting or publishing a user’s entity, editing or deleting their comment, and deleting their file are done as that user: the key names the author in
actingUserId, and the request runs exactly as theirs. Records created without an acting user (entities, files) belong to the app, and only a key naming nobody may change them. - Open reads are what that user sees — on entity, comment, event, space, workspace and user reads, a key naming a user gets exactly that user’s view, and a key naming nobody gets exactly the anonymous view (no drafts, no comment moderation details, only public events, no workspaces).
- Space, workspace and event roles still apply — on space admin, moderation and membership actions (editing a space, its rules and member roles; approving, declining, banning and unbanning members; handling reports and moderating content in a space; leaving or deleting a space), on workspace management (editing, deleting or transferring a workspace; changing its inherit flag; its invitations; listing its members and reading a member’s standing) and on event management (editing, cancelling and deleting an event; managing its hosts and invites; listing its invitees), the key must send
actingUserId, and the request has exactly that user’s role in the space or on the event, or their standing in the workspace.
/v8/:projectId/...), so no other header is needed:
x-sublay-project-id header: v8 refuses it with 400 project/wrong-location, whatever project it names. See Where each input goes.
When using the API from a client-side (browser/mobile) context without a service key, you are responsible for requesting and refreshing user access tokens, maintaining auth state, and handling real-time features (WebSockets) yourself if needed.
Option 3: Redux Store Integration
If your React application already has its own Redux store, you can integrate Sublay’s state directly into it rather than using the default built-in store. By default,SublayProvider creates an internal Redux store for Sublay’s state. If you have an existing store, using two separate Redux stores in one app is not ideal. SublayIntegrationProvider lets you pass your own Redux store configuration and mount Sublay’s reducers and middleware alongside your own.
This requires:
- Adding
sublayReducersandsublayApiReducerto yourcombineReducerscall - Adding
sublayMiddlewareto your middleware chain - Using
SublayIntegrationProviderinstead ofSublayProvider

