Skip to main content

Environment API

Info

App Bridge isn't versioned with Polaris. App Bridge APIs and web components are identical in every App Home reference version.

The Environment API provides access to information about the platform your app is running on. Use it to detect whether the app is embedded in the Shopify admin, running on Shopify Mobile, or running on Shopify POS.

  • Platform detection: Determine whether your app is running on mobile, desktop, or POS.
  • Responsive behavior: Adapt UI layout and features based on the current environment.
  • Embedded context: Check whether the app is running in an embedded context within the Shopify admin.
  • Device-specific features: Enable or disable features based on device capabilities like camera access or printing.

App Bridge automatically sets a CSS custom property, --shopify-safe-area-inset-bottom, on the document. This property provides the exact pixel value of host UI overlaying the bottom of your app, such as the Sidekick bar, or navigation controls on mobile. It applies wherever your app runs, including desktop and mobile web, and it defaults to 0px when no overlay is present.

App Bridge also adds an invisible spacer at the end of the <body> element: a body::after pseudo-element that's as tall as the overlay. The spacer lets in-flow content scroll above the overlay, so most apps work correctly without any changes. App Bridge doesn't pad the <body> element itself, so its computed padding-bottom stays 0px. If your app scrolls inside its own container instead of the page, then add var(--shopify-safe-area-inset-bottom, 0px) to the bottom padding of that container.

The spacer doesn't move elements that use position: fixed, such as sticky footers or floating action buttons. Use var(--shopify-safe-area-inset-bottom, 0px) for them:

  • For a floating element, such as a floating action button, add the variable to its bottom offset to position it above the overlay.
  • For a full-width bar, such as a sticky footer, keep bottom: 0 and add the variable to its padding-bottom. The bar's background reaches the bottom edge, and its content stays above the overlay. If you move a full-width bar up with the bottom offset instead, then page content scrolls into view in the gap below the bar.

The environment API is available on the shopify global. All properties are synchronous booleans.

Anchor to embedded
embedded
boolean

Whether the app is embedded in the Shopify admin.

Anchor to intent
intent
boolean

Whether the app is running as an intent.

Anchor to mobile
mobile
boolean

Whether the app is running inside the Shopify Mobile app.

boolean

Whether the app is running inside the Shopify POS app.

Examples

js

shopify.environment;
// => { mobile: false, embedded: true, pos: false }

Was this page helpful?