Skip to main content

Device

<Engine>
<Device bg="black" mode="mobile" showFPS>
<MyGame />
</Device>
</Engine>

This component provides access to the dimensions of the device on which it's running. Nested component can access this information using the useDevice hook.

Not only that, but when your app is running in a browser, in development, if the mode prop is set to "mobile" your game runs inside of simulated mobile frame. In addition, you can rotate and shake the simulated device, and the APIs that report device events (orientation and motion) report appropriate values.

Props

PropTypeDefaultDescription
bgstring"white"Background color of the device.
mode"mobile" | "desktop""desktop"Size of the device in development.
hideClosebooleanfalseHide the "close" icon in the top left corner of the device.
showFPSbooleanfalseDisplay an FPS counter in the top right corner of the device.
allowShakebooleanfalseWhen enabled, in development, pressing "S" causes the device to shake, and the values returned by the useMotion hook reflect this.
allowTiltbooleanfalseWhen enabled, in development, pressing "G" and "H" rotates the simulated device, and the values returned by the useOrientation hook reflect this.