Detect the platform

Detect whether your scene is running on mobile, desktop, or web.

The @dcl/sdk/platform module lets your scene check which client a player is using, so you can adapt your UI, controls, and gameplay accordingly. This is the recommended way to deliver a great experience across all clients without forking your scene.

Available functions

import { getPlatform, isMobile, isDesktop, isWeb } from '@dcl/sdk/platform'
  • getPlatform() — returns the current platform as 'mobile' | 'desktop' | 'web' | null. Returns null until the explorer has reported its platform back to the scene (this happens shortly after the scene starts).

  • isMobile() — returns true if the player is on the mobile client.

  • isDesktop() — returns true if the player is on the desktop client.

  • isWeb() — returns true if the player is on the web client.

Branch your UI by platform

A common pattern is to set up a different UI for mobile and desktop players:

import { isMobile, isDesktop } from '@dcl/sdk/platform'

function setupUI() {
  if (isMobile()) {
    // Larger buttons, simpler layout for touch
    createMobileUI()
  } else if (isDesktop()) {
    // Denser layout tuned for keyboard and mouse
    createDesktopUI()
  }
}

You can also use the same pattern to:

  • Show or hide on-screen instructions tailored to each input method.

  • Replace small clickable elements with larger touch targets on mobile.

  • Disable input bindings that are not easily available on mobile (see Input on mobile).

Checking the raw platform value

If you need to handle multiple platforms in a single switch, use getPlatform():

Last updated