Registry / messaging / stayge-ws-client-sdk

stayge-ws-client-sdk

JSON →
library0.1.35jsnpmunverified

Stayge WebSocket Client SDK for browser and React Native environments. This SDK provides a unified interface for connecting to Stayge's WebSocket gateway server with built-in heartbeat, reconnection, and event-driven message handling. The current stable version is 0.1.35, and it is released with no fixed cadence. Key differentiators include separate entry points for React (`react`) and React Native (`react-native`), automatic JSON parsing, and built-in heartbeat with customizable intervals and timeouts. It requires token issuance via a REST API for topic subscriptions.

npm install stayge-ws-client-sdk
INSTALL
IMPORT
SIG · STAYGE-WS-CLIENT-S
S
stayge-ws-client-sdk
messagingjavascriptv0.1.35
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

getWebSocketClient
import { getWebSocketClient } from 'stayge-ws-client-sdk/react'
import { getWebSocketClient } from 'stayge-ws-client-sdk'
ESM-only. Must specify '/react' or '/react-native' subpath. Default import does not exist.
WsError
import { WsError } from 'stayge-ws-client-sdk/react'
const { WsError } = require('stayge-ws-client-sdk/react')
ESM-only. WsError is a class for error handling with code and topic fields.
getWebSocketClient (React Native)
import { getWebSocketClient } from 'stayge-ws-client-sdk/react-native'
import { getWebSocketClient } from 'stayge-ws-client-sdk/react'
Ensure you import from the correct platform-specific subpath. React and React Native have separate implementations.

Connects to a Stayge WebSocket server, subscribes to a topic, handles messages and errors.

import { getWebSocketClient, WsError } from 'stayge-ws-client-sdk/react'; const ws = getWebSocketClient(); const token = process.env.WS_TOKEN ?? ''; ws.connect({ url: 'wss://dev.linc.fan/ws/linc' }); ws.onConnect({ callback: () => console.log('connected') }); ws.onMessage<{ title: string; body: string }>({ topic: 'openchat/12345', callback: (topic, payload) => { console.log(`Received: topic=${topic}, payload=${JSON.stringify(payload)}`); }, }); ws.subscribe({ topic: 'artist:12345:live', token }); ws.onError({ callback: (error: WsError) => { if (error.code === 'connectionLost') console.log('Connection lost'); }});
Debug
Known issues
gotchaMust import from '/react' or '/react-native' subpath; root import does not exist.
fix
Use import { getWebSocketClient } from 'stayge-ws-client-sdk/react' for React projects.
affects: >=0.0.0
gotchaTopic subscriptions require a token obtained from the REST API; connect does not handle auth.
fix
Call POST /api/youmeon/v1/websocket/token to get a token, then pass it to ws.subscribe({ topic, token }).
affects: >=0.0.0
gotchaHeartbeat is enabled by default with 20s ping interval; customize via connect options.
fix
Specify heartbeat.pingIntervalMs in connect() to change interval.
affects: >=0.1.0
gotchaEvent handlers (onConnect, onMessage, etc.) can be registered before or after connect, but message handlers require the topic to be known at registration time.
fix
Register event handlers before connect() if you need to guarantee they are active from the start.
affects: >=0.0.0
Errors
Common errors & fixes
Cannot find module 'stayge-ws-client-sdk' or its corresponding type declarations.
Importing from root instead of platform subpath.
fix
Use import { getWebSocketClient } from 'stayge-ws-client-sdk/react' or '/react-native'.
Property 'subscribe' does not exist on type 'WebSocketClient'
Trying to subscribe before connect or with incorrect token.
fix
Ensure you call ws.connect() first and pass a valid token to subscribe().
TypeError: (0 , stayge_ws_client_sdk__WEBPACK_IMPORTED_MODULE_0__.getWebSocketClient) is not a function
Attempting to use CJS require() on an ESM-only package.
fix
Use ES import syntax: import { getWebSocketClient } from 'stayge-ws-client-sdk/react'.
WsError: subscribeError - topic: 'artist:12345:live', message: 'Invalid token'
Token is expired or invalid for the subscribed topic.
fix
Obtain a fresh token via POST /api/youmeon/v1/websocket/token and call ws.subscribe again.
Upgrade
Version history
0.1.35latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
20 hits · last 30 days
node
18
Amazon
1
OpenAI (training)
1
Resources
stayge-ws-client-sdk — npm install stayge-ws-client-sdk · libregistry