TypeScript SDK overview
Choose the correct typed client for trusted servers, app users, dashboard sessions, realtime, and webhooks.
Install
npm install @vchatsdk/sdk-typescriptThe SDK is ESM, side-effect free, and exports portable declarations for supported browser and Node consumers. Import only from the package root or the documented webhooks/server subpath.
Choose the right client
| Client | Credential/runtime | Use it for |
|---|---|---|
| VChatClient | App-user token; browser, mobile web, or Node | Ergonomic REST, realtime lifecycle, recovery, and channel handles |
| AppUserClient | App-user token | Lower-level app-user REST resource facades |
| AppServerClient | Application credential; trusted server only | Users, channels, memberships, messages, threads, search, and moderation |
| Dashboard and control-plane clients | Dashboard session cookie | Organizations, applications, environments, credentials, webhooks, usage, and support |
| HealthClient | No credential | Readiness checks |
| verifyWebhook | Webhook signing secret; Node server | Verify raw signed webhook bytes before decoding |
Runtime rules
- Use HTTPS outside explicit loopback development endpoints.
- Pass opaque cursors unchanged; do not parse or manufacture them.
- Cancel obsolete work with AbortSignal and a bounded timeout.
- Use stable ApiError fields for recovery; do not show raw server messages.
- Dispose realtime listeners, subscriptions, and clients when their owning session ends.