🎮 Beta Gamer

Provider setup

BetaGamerProvider is the root wrapper for both React and React Native SDKs. It opens the Socket.IO connection, decodes the session token, and makes game state available to all child components via context.

npm install @beta-gamer/react
# React Native:
npm install @beta-gamer/react-native react-native-webview

Props

PropTypeRequiredDefaultDescription
tokenstringYesJWT session token from POST /v1/sessions. Never hardcode — fetch from your backend.
serverUrlstringNo"https://api.beta-gamer.com"Base URL of the Beta Gamer API server.
socketPathstringNo"/socket.io"Socket.IO path. Only change if self-hosting.
connectSocketbooleanNotrueSet false when using native board components (ChessBoard, CheckersBoard, Connect4Board, TictactoeBoard from @beta-gamer/react-native) — they open their own socket and the provider should not create a duplicate.
themeobjectNosession defaultsOverride theme tokens at runtime (see Theming).
onErrorfunctionNoCalled with an Error when the socket fails to connect.

Usage

import { BetaGamerProvider } from '@beta-gamer/react';

// sessionToken comes from your server — never expose your API key to the client
export default function GamePage({ sessionToken }: { sessionToken: string }) {
  return (
    <BetaGamerProvider
      token={sessionToken}
      serverUrl="https://api.beta-gamer.com"
      onError={(err) => console.error('Socket error:', err)}
    >
      {/* game components go here */}
    </BetaGamerProvider>
  );
}
💡 The provider connects to the correct Socket.IO namespace automatically based on the game type encoded in the session token. You don't need to specify the namespace manually.
Beta Gamer GaaS API — questions? support@beta-gamer.com