Skip to main content
Mentra Miniapp SDK betaThe SDK is in beta, so its APIs may change before general availability.There is currently no way to distribute a miniapp built with the Miniapp SDK. In a future release, developers will upload miniapps through the Mentra Developer Console, and users will download them from the Mentra Miniapp Store. Neither service supports Miniapp SDK distribution in MentraOS 3.0.Only use the Miniapp SDK if you are comfortable with these limitations.Developing on Mentra Live? We recommend using the Mentra Bluetooth SDK.The developer tools are available in the Mentra App under Settings → Miniapp Developer Settings.Share feedback with an in-app bug report, on Discord, or by email at help@mentra.glass.
Your miniapp UI runs in a WebView inside the Mentra App, and the host draws its own chrome on top. Two things overlap your content: the device safe-area insets (notch, status bar, rounded corners) and a floating capsule menu the host parks in the top-right. If you lay out edge-to-edge, your header sits under the notch and your top-right button sits under the capsule, where taps go to the host instead of your app. useSafeArea() reads both regions so your layout can pad around them. It imports from @mentra/miniapp/react, the UI layer of the two-layer architecture.
The host injects these values before your content loads. The hook reads them once at mount. They don’t change at runtime today, so there’s nothing to re-render on.

useSafeArea()

Returns an object with two fields. insets always has all four sides, defaulting to 0 when the host provides none (for example, a browser preview): capsuleMenu is the rect of the floating control in the top-right. Use it to keep interactive elements out from under the menu, since taps there reach the host.
Coordinates are in CSS pixels. Always handle capsuleMenu === null so your layout still works outside the Mentra App and on hosts that don’t draw a menu.

useCapsuleHeaderStyle()

When you want your own header markup but want the capsule alignment done for you, useCapsuleHeaderStyle() returns a CSSProperties object you spread onto your header element. It positions the row vertically centered on the capsule menu and reserves room on the right so your content doesn’t slide under it.
It accepts an options object. All four are optional and have fallbacks used when the host doesn’t render a capsule menu. The returned style sets display: flex with justifyContent: "space-between", so a left child and a right child split to opposite ends of the row.

<MiniappHeader>

For a stock header, <MiniappHeader> renders the aligned row for you. It has three slots (left, title, right) and respects the safe area and capsule menu the same way. It also accepts every useCapsuleHeaderStyle() option as a prop.
<MiniappHeader> also forwards leftPadding, rightGap, fallbackHeight, and fallbackMarginTop through to the underlying useCapsuleHeaderStyle(). The component ships only the layout, so use className or style for colors and fonts.

Next steps

React webviews

The UI layer overview and its hooks.

Two-layer architecture

How the UI and background layers split and talk.