Best Practices & Type Definitions
A summary of recommended patterns and the main TypeScript types for quick reference.
Best Practices
1. Check connection before sending messages
if (client.state.isConnected) {
client.sendUserTextMessage('Hello');
}2. Handle errors
try {
await client.connect(config);
} catch (err) {
console.error('Connection failed', err);
}3. Unsubscribe from events when needed
const off = client.on('message', handler);
off();4. Disconnect on cleanup
5. Keep UI responsive with stateChange
Key Types
Last updated
Was this helpful?