Skip to main content

SocketProvider

Mount one SocketProvider below OvokProvider. It reads the current client's base URL and access token, connects to the Ovok events endpoint, and provides the socket and connection state to descendants.

import { OvokProvider } from "@ovok/core";
import { SocketProvider } from "@ovok/native/socket";

<OvokProvider client={client}>
<SocketProvider
onConnect={handleConnect}
onDisconnect={handleDisconnect}
onConnectionError={handleConnectionError}
>
<RealtimeFeatures />
</SocketProvider>
</OvokProvider>

The provider exposes callbacks for connection errors, transport errors, ping, and server-pushed log payloads. Keep onLogs free of identifiers and tokens. Mounting multiple providers opens multiple server connections.

The current network reconnection path can replace the socket without restoring its listener set. Treat reconnect as best effort and keep a retry or refresh path for features that require live events.

See Socket hooks for reading the connection and subscribing to AI session messages.