Real-time sockets
Connect to Ovok real-time events with SocketProvider and its hooks
- Stable unknown
- Release candidate since 1.16.1-rc.3
- Development since 1.16.1-dev.2111+9796905
Use the socket module only for SDK features that consume Ovok real-time events.
SocketProvider exposes a Socket.IO client to descendants; ordinary API requests
still go through the native Ovok client.
import { OvokProvider } from "@ovok/core/next/react";
import { SocketProvider } from "@ovok/native/socket";
<OvokProvider client={client}>
<SocketProvider>
<RealtimeScreen />
</SocketProvider>
</OvokProvider>Read the connection through useSocket and subscribe to AI events with
useAiEventListener from within the provider. Keep event handling idempotent because
real-time delivery can repeat or arrive after a screen has changed. Remove any
application-owned listeners when their owning screen unmounts.
The provider disconnects when the session ends or the network goes offline. It reconnects the same socket, with its listeners, when network access returns. A new session token replaces the old socket connection. Provide a refresh path for user-visible features that depend on live events.
References
API reference
Every export of @ovok/native/socket, with signatures, props and types, is in the socket API reference.
Last updated on