# SocketProvider

Canonical page: https://docs.ovok.com/native-sdk/guide/components/socket/socket-provider

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.

```tsx
import { OvokProvider } from "@ovok/core/next/react";
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](/native-sdk/guide/components/socket/hooks/) for reading the connection and subscribing to AI
session messages.
