Webview Bridge SDK
Whenever the mobile app shows a page of your online store (a policy page, a blog post, a third-party app page, a chat widget, ...), it loads that page in a webview. The Webview Bridge SDK is a small JavaScript library that runs on your storefront and connects that webview to the native app. It:
- detects that the page is running inside the mobile app,
- hides the website's own header, footer and other chrome, since the app already has native ones,
- opens product, collection and cart links as native app screens instead of in the webview,
- syncs the customer's login and cart with the app,
- lets you run your own code to optimize the page for the app.
Enabling the SDK
The SDK ships with the Evlop Shopify app as a theme app embed. To turn it on:
- In your Shopify admin, go to Online Store → Themes → Customize.
- Open App embeds in the left sidebar.
- Enable Mobile app embed and save.
Once enabled, the SDK is loaded on every storefront page but only activates when the page is opened inside the mobile app - regular website visitors are not affected.
Embed settings
The app embed has a few settings that tell the SDK which parts of your theme to show or hide inside the app. The defaults work for most Online Store 2.0 themes.
| Setting | Default | What it's used for |
|---|---|---|
| Container element CSS selector | body | The element whose children are hidden when a specific embed (e.g. a chat widget) is opened, so only that widget is visible. |
| Main content element CSS selector | main, #MainContent | The part of the page that stays visible for regular pages. |
| Header element CSS selector | header, .shopify-section.shopify-section-group-header-group | The theme header - hidden in the app. |
| Footer element CSS selector | footer, .shopify-section.shopify-section-group-footer-group | The theme footer - hidden in the app. |
| Elements to hide CSS selector | .evlop-mobile-app__hidden | Any additional elements that should be hidden in the app. |
What happens when a page loads in the app
- A white loading overlay covers the page, so customers never see the desktop layout flash.
- Once the DOM is ready, the SDK initializes: it adds the
evlop-mobile-app-embedclass to<body>and hides the header, footer and "elements to hide". - The SDK adds your app-only stylesheets and scripts to the page.
- The SDK dispatches the
evlop-mobile-app:readyevent ondocumentand removes the overlay.
These are the supported ways for your own code to detect the app and adjust the page:
- the
evlop-mobile-app-embedclass on<body>, - the
evlop-mobile-app:readyevent, - app-only stylesheets and scripts, loaded with
<link rel="stylesheet+evlop-mobile-app">and<script type="text/javascript+evlop-mobile-app">tags.
Learn more:
- Styling Pages with CSS - hide or restyle elements in the app using the
evlop-mobile-app-embedclass, or an app-only stylesheet. - Running JavaScript in the App - run app-only code with an app-only script file, or inline on the
evlop-mobile-app:readyevent. - Common Use Cases - worked examples, such as disabling the cart drawer or preventing popups inside the app.