Environment API
Detect device characteristics, platform information, and development mode. Use these APIs for responsive design, platform-specific behavior, and conditional debug logging.
Quick Start
import RundotGameAPI from '@series-inc/rundot-game-sdk/api'
// Quick platform checks
const isMobile = RundotGameAPI.system.isMobile()
const isWeb = RundotGameAPI.system.isWeb()
if (isMobile) {
enableTouchControls()
} else {
enableKeyboardControls()
}Device Information
Get detailed device characteristics for responsive layouts and feature detection.
const device = RundotGameAPI.system.getDevice()
// device contains:
// {
// screenSize: { width: 1920, height: 1080 },
// viewportSize: { width: 1280, height: 720 },
// orientation: 'landscape',
// pixelRatio: 2,
// fontScale: 1,
// deviceType: 'phone',
// hapticsEnabled: true,
// haptics: { supported: true, enabled: true }
// }
// Responsive layout based on screen size
if (device.screenSize.width < 768) {
renderMobileLayout()
} else {
renderDesktopLayout()
}
// Handle high-DPI displays
if (device.pixelRatio > 1) {
loadHighResAssets()
}
// Adapt to font scaling (accessibility)
if (device.fontScale > 1.2) {
useCompactUI()
}deviceType
Typical host
phone
Mobile phone
tablet
Tablet
desktop
Desktop browser or desktop app
tv
Living-room TV host (for example Fire TV)
TV-hosted games receive deviceType: 'tv'. Use the device type to select a ten-foot layout and controller prompts. Read environment.capabilities for channel-specific availability; Fire TV v1 reports ads, purchases, and subscriptions as unavailable, but another TV channel can expose a different capability set.
Environment Information
Get runtime environment details for conditional logic and debugging.
Platform Quick Checks
Safe Area
Get the padding your game needs to avoid drawing under device notches and host UI (toolbar / feed header). Use these insets to keep buttons, HUD, and important content out from under the host chrome.
getSafeArea(): SafeArea
Returns the padding (in pixels) needed to avoid device notches and host UI. The value combines the toolbar / feed-header height with the device's own safe areas.
left
number
Left inset in pixels
top
number
Top inset in pixels
right
number
Right inset in pixels
bottom
number
Bottom inset in pixels
Add to Home Screen
Prompt players to pin your game to their home screen for faster re-entry. Check canAddToHomeScreen() before showing a "pin this game" CTA, then call addToHomeScreen() from the tap handler.
canAddToHomeScreen(): Promise<boolean>
Resolves to whether the platform can present an "Add to Home Screen" prompt for the running game right now. Call this before showing your own "pin this game" CTA so the CTA isn't displayed when it would no-op.
Resolves false when:
the host has not surfaced a deferred install prompt (the browser hasn't decided the site is installable, or the user already installed it),
the platform is iOS Safari (no programmatic install API),
the running game has no thumbnail,
a per-session cooldown is active because the user already dismissed the prompt for this game during this app session.
addToHomeScreen(): Promise<AddToHomeScreenResult>
Shows the host's "Add to Home Screen" confirmation modal and, on confirm, triggers the platform install prompt. Resolves with { added: boolean }.
added
boolean
true if the user accepted the install prompt; false if they cancelled or no prompt could be shown
Use Cases
Responsive Design
Conditional Feature Enabling
Platform-Specific Assets
API Reference
capabilities
PlatformCapabilities
Resolved host capability flags (direct getter)
system.getDevice()
DeviceInfo
Screen size, viewport, orientation, pixel ratio, haptics
system.getEnvironment()
EnvironmentInfo
Platform, version, dev mode, browser info
system.getSafeArea()
SafeArea
Pixel insets to avoid notches and host UI
system.isMobile()
boolean
Quick check if on mobile device
system.isWeb()
boolean
Quick check if on web platform
system.isSteamDesktop()
boolean
Quick check if on Steam, desktop/laptop (non-Deck)
system.isSteamDeck()
boolean
Quick check if on Steam Deck hardware
system.canAddToHomeScreen()
Promise<boolean>
Whether an Add-to-Home-Screen prompt can be shown now
system.addToHomeScreen()
Promise<AddToHomeScreenResult>
Show the install prompt; resolves { added }
DeviceInfo Properties
screenSize
{ width, height }
Physical screen dimensions
viewportSize
{ width, height }
Available viewport dimensions
orientation
string
'portrait' or 'landscape'
pixelRatio
number
Device pixel ratio (1, 2, 3, etc.)
fontScale
number
System font scale factor
deviceType
string
Device type (phone, tablet, desktop, or tv)
hapticsEnabled
boolean
Whether haptics are enabled
haptics
{ supported, enabled }
Detailed haptics status
EnvironmentInfo Properties
isDevelopment
boolean
Whether running in development mode
platform
string
Platform identifier (ios, android, web)
platformVersion
string
Platform version string
browserInfo
object
Browser details (optional, web only)
browserInfo.browser
string
Browser name
browserInfo.userAgent
string
Full user agent string
browserInfo.isMobile
boolean
Is mobile browser
browserInfo.isTablet
boolean
Is tablet browser
browserInfo.language
string
Browser language setting
capabilities
object
Channel-static host-gated feature availability (always present)
capabilities.ads
boolean
Rewarded/interstitial ads can be shown on this platform
capabilities.purchases
boolean
One-time/consumable in-app purchases can be initiated (e.g. currency top-up, store, shop). Does not cover recurring subscriptions — see capabilities.subscriptions
capabilities.subscriptions
boolean
Recurring subscription purchases can be initiated on this platform. false where third-party billing is banned (e.g. Steam) — hide subscription upsell/paywalls. Reading an existing subscriber's status is unaffected
isSteamDesktop
boolean
Whether the game runs on Steam on a desktop/laptop PC (the Steam client, not Deck hardware). Channel-static for the session. Mutually exclusive with isSteamDeck; to ask "am I on Steam at all?" check `isSteamDesktop
isSteamDeck
boolean
Whether the game runs on Steam Deck hardware. Device-static for the session — branch UX on it (gamepad-first navigation, handheld layout, larger touch targets). Mutually exclusive with isSteamDesktop. Also available as system.isSteamDeck(). A host that predates this field omits it and it defaults to false.
capabilitiesis determined by the distribution channel and is fixed for the session (it is not live state —capabilities.adsbeingtruedoes not mean an ad is loaded right now; useAdsApi.isRewardedAdReadyAsync()for that).capabilities.purchasescovers one-time/consumable purchase surfaces (store, shop, currency top-up);capabilities.subscriptionsseparately covers recurring subscription purchases. On Steam, for example,purchasesistrue(consumables work via Steam microtransactions) butsubscriptionsisfalse(no third-party billing) — so hide subscription upsell/paywalls while keeping the currency store. When a flag isfalse, hide all of that category's purchase-initiating UI, not just one button; reading an existing subscriber's status is always allowed. Branch your UI on these flags at first render. For backward compatibility, a host that predates a field omits it and each capability defaults totrue, so existing behavior is preserved on web and mobile — exceptsubscriptions, which when absent inherits the legacypurchasesvalue (thentrue), so a pre-split host that sentpurchases: false(e.g. Steam) is correctly treated assubscriptions: falsetoo.
Capabilities and Disabled Outcomes
Read platform capability flags from RundotGameAPI.capabilities or RundotGameAPI.system.getEnvironment().capabilities. Both read the host environment at call time.
When a host disables a capability (false), gated SDK methods do not send a remote procedure call (RPC). They return a disabled outcome or reject immediately.
iap.spendCurrency()
purchases
Resolves { success: false, error: 'CAPABILITY_DISABLED' }. Sends no RPC.
iap.openStore()
purchases
Rejects with RundotApiError (CAPABILITY_DISABLED). Sends no RPC.
iap.purchaseSubscription()
subscriptions
Resolves { success: false, error: 'CAPABILITY_DISABLED' }. Sends no RPC.
shop.purchase()
purchases
Rejects with RundotApiError (CAPABILITY_DISABLED). Sends no RPC.
shop.purchaseCollectionItem()
purchases
Rejects with RundotApiError (CAPABILITY_DISABLED). Sends no RPC.
ads.isRewardedAdReadyAsync()
ads
Resolves false. Sends no RPC.
ads.isInterstitialAdReadyAsync()
ads
Resolves false. Sends no RPC.
ads.showRewardedAdAsync()
ads
Resolves false. Sends no RPC.
ads.showInterstitialAd()
ads
Resolves false. Sends no RPC.
Ungated methods send their RPC normally. These methods include wallet reads, catalog reads, order lookups, and subscription status checks.
SafeArea Properties
left
number
Left inset in pixels
top
number
Top inset in pixels
right
number
Right inset in pixels
bottom
number
Bottom inset in pixels
AddToHomeScreenResult Properties
added
boolean
true if the user accepted the install prompt (or the prompt flow launched on platforms that don't surface acceptance); false if cancelled or no prompt could be shown
Best Practices
Cache environment info at startup once the SDK has initialized; for device dimensions and safe-area insets, subscribe to
RundotGameAPI.lifecycles.onSafeAreaChanged/onDeviceChangedor use CSS variables (--rundot-safe-area-*) because screen geometry and insets update dynamically on rotation or resize.Use
isMobile()andisWeb()for quick checks; usegetDevice()andgetEnvironment()for detailed information.Test your responsive logic across different device types and orientations.
Don't rely solely on device type; consider screen size for layout decisions.
Use
isDevelopmentto gate debug features, not for feature flags (use LiveOps config values / experiments instead — see LIVEOPS.md).
Last updated