Getting started
Every game client needs a project key, the Rudder API endpoint, and optionally the realtime endpoint. Device login creates the access token used by the rest of the SDK services.
1. Get a project key
Open the Rudder dashboard, create or select a project, and copy its project key. Keep the key in game configuration so the same build can point at different projects or environments.
| Setting | Production value |
|---|---|
| Project key | YOUR_PROJECT_KEY |
| API URL | https://api.rudder.build |
| Realtime URL | wss://realtime.rudder.build/api/realtime/ws |
2. Authenticate the player
Device login sends the project key, device id, region, and language to
/sdk/v1/authorization/device. The SDK stores the returned access
and refresh tokens through its configured token store.
import { LiveOpsClient } from "@rudder/web-sdk";
const rudder = new LiveOpsClient({
projectKey: "YOUR_PROJECT_KEY",
baseUrl: "https://api.rudder.build",
realtimeUrl: "wss://realtime.rudder.build/api/realtime/ws"
});
await rudder.auth.loginViaDevice({
region: "eu",
language: "en"
}); 3. Run smoke checks
After login, verify that the token works with a low-risk read and one analytics event. These calls use the same authenticated transport as stores, leaderboards, storage, UGC, and scenarios.
const profile = await rudder.player.getProfile();
await rudder.remoteConfig.load();
rudder.analytics.track("sdk_smoke_check", {
playerId: profile.player?.id ?? "unknown"
});
await rudder.analytics.flush(); 4. Restore runtime state
Scenario plans can contain waits and client-visible actions. Call
restore() when the client starts so persisted scenario state can
resume after a reload or game restart.
rudder.restore();
rudder.scenarios.on("notification", (notification) => {
showInGameMessage(
notification.get("title", "Event update"),
notification.get("message", "")
);
notification.complete();
});
await rudder.scenarios.send("player_login"); 5. Shut down cleanly
Dispose the client when the page, scene, or game session ends. This flushes analytics timers and disconnects realtime transport.
window.addEventListener("beforeunload", () => {
rudder.dispose();
});
For C# integrations, the same flow applies: configure transports, call
Auth.LoginViaDeviceAsync, then call SDK services through the
authenticated client.