Profiles API
Sync access to the active player's identity so you can personalize UI on first paint, gate features, or tag analytics without extra calls.
Quick Start
import RundotGameAPI from '@series-inc/rundot-game-sdk/api'
const profile = RundotGameAPI.getProfile()
console.log(profile.id, profile.username)getProfile() returns the cached snapshot from the host handshake. The SDK initializes automatically on module import. Static imports wait for top-level await to complete. The SDK catches initialization errors internally. Module import can resolve even when initialization fails. If initialization fails, getProfile() throws an error.
try {
const profile = RundotGameAPI.getProfile()
hud.setName(profile.username)
} catch (err) {
// Initialization failed or host sent an incomplete profile
}Fields
id
string
Stable player identifier; safe as a primary key.
username
string
Display handle for leaderboards or invites.
name
string | undefined
Optional display name. Populated only during local Playground testing; the production host always omits it. See note below.
avatarUrl
string | null | undefined
HTTPS avatar URL. null if the player has none, or undefined if the host omits it; null-check before use.
isAnonymous
boolean | undefined
true when the player is in guest/unsigned mode. Optional: may be undefined if the host omits it, so check profile.isAnonymous === true rather than assuming it's always present.
Usage Ideas
Bootstrap HUD/nameplates with
profile.usernamebefore gameplay starts.Attach
profile.idto analytics, matchmaking, or social payloads for attribution.Require login by checking
profile.isAnonymousbefore premium flows or social invites.
Deprecated
getCurrentProfile(): Profile
Last updated