JavaScript / Web
Use TypeScript to connect wukongimjssdk and manage WebSocket, messages, conversations, and channel profiles.
wukongimjssdk is the full WuKongIM JavaScript SDK. It manages WebSocket, message delivery, an in-memory conversation list, and channel profiles for browsers, H5, and separately verified JavaScript runtimes.
These guides target wukongimjssdk 1.3.5 and use TypeScript throughout.
Before you start
Prepare:
- a WuKongIM WebSocket endpoint reachable from the target runtime;
- two test users, such as
aliceandbob; - a
uid,token, andws://orwss://endpoint returned by your application server; - a frontend project using npm, pnpm, or Yarn.
The browser must not hold an admin secret
The browser should receive only the current user's short-lived token and endpoint from your application server. Keep user creation, token issuance, and access control on the server.
Recommended order
Quickstart
Install the SDK, connect a user, and send the first online text message.
Connection
Handle endpoints, states, automatic reconnection, and page cleanup.
Messages
Send, receive, synchronize, and correlate message states.
Conversations
Maintain the in-memory chat list and unread counts.
Channels
Load user, group, and subscriber profiles.
Advanced
Add custom content, offline recovery, and UniApp migration.
The repository contains a runnable two-session example at docs-site/examples/javascript-web-quickstart. Read these guides to learn the API first; run the example when you are ready to connect a real service.
Read Core Concepts first if “channel” or “conversation” is unfamiliar. Open the API Reference when you only need a method name.