Software Development Kits
[EVM] React Components SDK
- Overview
- Getting started
- Theming
- Wallet connect
- Framework Guides
- Page Components
- Block Components
[EVM] React Hooks SDK
[EVM] Core SDK
[EVM] Perp SDK
API Requests
useWS
Allows you to subscribe to public topics.
subscribe(
topic: string | { [key:string]:any },
callback: WSMessageHandler | Omit<WSMessageHandler, "onUnsubscribe">,
once?: boolean,
id?: string
): unsubscribe | undefined
Subscribing to the trade
topic:
const ws = useWS();
useEffect(() => {
const unsubscripe = ws.subscribe(
{
id: `${symbol}@trade`,
event: "subscribe",
topic: `${symbol}@trade`,
ts: Date.now()
},
{
onMessage: (data: any) => {
//
}
}
);
() => {
// Unsubscribes when the component unloads
unsubscribe();
};
}, []);
Subscribing to private topics
Subscribing to the executionreport
topic:
const ws = useWS();
useEffect(() => {
const unsubscript = ws.privateSubscribe(
{
id: "executionreport",
event: "subscribe",
topic: "executionreport",
ts: Date.now()
},
{
onMessage: (data) => {
// do something
}
}
);
() => {
// Unsubscribes when the component unloads
unsubscribe();
};
}, []);
On this page