> For the complete documentation index, see [llms.txt](https://docs.decentraland.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.decentraland.org/creator/content-creator-es/desarrollar-para-movil/desarrollar/detect-platform.md).

# Detectar la plataforma

Detecta si tu escena se está ejecutando en móvil, escritorio o web.

Usa la función `isMobile()` para adaptar la UI, los controles y la jugabilidad específicamente para dispositivos móviles. Esta es la forma recomendada de ofrecer una gran experiencia en todos los clientes sin tener que bifurcar por completo la lógica de la escena.

## Funciones disponibles

```ts
import { getPlatform, isMobile, isDesktop, isWeb } from '@dcl/sdk/platform'
```

* **`getPlatform()`** — devuelve la plataforma actual como `'mobile' | 'desktop' | 'web' | null`. Devuelve `null` hasta que el Explorer haya informado a la escena de la plataforma (esto ocurre poco después de que se inicia la escena).
* **`isMobile()`** — devuelve `true` si el jugador está usando el cliente móvil.
* **`isDesktop()`** — devuelve `true` si el jugador está usando el cliente de escritorio.
* **`isWeb()`** — devuelve `true` si el jugador está usando el cliente web.

{% hint style="warning" %}
**📔 Nota**: Estas funciones leen un valor que se establece de forma asíncrona cuando se inicia la escena, y nada garantiza que ya esté disponible cuando se ejecute `main()` . Si las llamas demasiado pronto, es posible que todavía devuelvan `null` / `false`. Para evitarlo, aplaza cualquier configuración que dependa de la plataforma hasta que `getPlatform()` devuelva algo distinto de `null`, por ejemplo, comprobándolo dentro de un sistema:

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

function platformCheckSystem() {
  if (getPlatform() === null) return
  engine.removeSystem(platformCheckSystem)
  setupUI()
}

engine.addSystem(platformCheckSystem)
```

{% endhint %}

## Adapta la UI según la plataforma

Un patrón habitual consiste en configurar una UI diferente para los jugadores móviles y de escritorio:

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

function setupUI() {
  if (isMobile()) {
    // Botones más grandes y diseño más sencillo para pantallas táctiles
    createMobileUI()
  } else if (isDesktop()) {
    // Diseño más denso, optimizado para teclado y ratón
    createDesktopUI()
  }
}
```

También puedes usar el mismo patrón para:

* Mostrar u ocultar instrucciones en pantalla adaptadas a cada método de entrada.
* Reemplaza los elementos pequeños en los que se puede hacer clic por objetivos táctiles más grandes en dispositivos móviles.
* Desactiva las vinculaciones de entrada que no estén fácilmente disponibles en dispositivos móviles (consulta [Entrada en dispositivos móviles](https://docs.decentraland.org/creator/content-creator-es/desarrollar-para-movil/desarrollar/input-on-mobile.md)).

## Comprobar el valor sin procesar de la plataforma

Si necesitas gestionar varias plataformas en un único switch, usa `getPlatform()`:

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

const platform = getPlatform()

switch (platform) {
  case 'mobile':
    // comportamiento específico para móviles
    break
  case 'desktop':
    // comportamiento específico para escritorio
    break
  case 'web':
    // comportamiento específico para la web
    break
  case null:
    // plataforma aún desconocida
    break
}
```

## Relacionado

* [Área segura en dispositivos móviles](https://docs.decentraland.org/creator/content-creator-es/desarrollar-para-movil/desarrollar/safe-area.md)
* [Buenas prácticas de UI para móviles](https://docs.decentraland.org/creator/content-creator-es/desarrollar-para-movil/desarrollar/ui-best-practices.md)
* [UI en pantalla](https://docs.decentraland.org/creator/content-creator-es/scenes-sdk7/ui-2d/onscreen-ui.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.decentraland.org/creator/content-creator-es/desarrollar-para-movil/desarrollar/detect-platform.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
