# Detect the platform

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

```ts
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.

{% hint style="warning" %}
**📔 Note**: These functions read a value that is populated asynchronously when the scene starts. If you call them in the very first frame, they may still return `null` / `false`. For UI setup, the safest place to call them is from the `main()` function or any code that runs after the first frame.
{% endhint %}

## Branch your UI by platform

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

```ts
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](/creator/scenes-sdk7/building-for-mobile/input-on-mobile.md)).

## Checking the raw platform value

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

```ts
import { getPlatform } from '@dcl/sdk/platform'

const platform = getPlatform()

switch (platform) {
  case 'mobile':
    // mobile-specific behavior
    break
  case 'desktop':
    // desktop-specific behavior
    break
  case 'web':
    // web-specific behavior
    break
  case null:
    // platform not yet known
    break
}
```

## Related

* [Mobile safe area](/creator/scenes-sdk7/building-for-mobile/safe-area.md)
* [UI best practices for mobile](/creator/scenes-sdk7/building-for-mobile/ui-best-practices.md)
* [On-screen UI](/creator/scenes-sdk7/2d-ui/onscreen-ui.md)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.decentraland.org/creator/scenes-sdk7/building-for-mobile/detect-platform.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
