Migrate your app to Shopify App Bridge
If you have an app that uses a previous version of Shopify App Bridge (3.x.x or earlier), this guide explains how to upgrade to the latest Shopify App Bridge. The most significant change in Shopify App Bridge is how you access APIs.
If you're using React components and hooks from @shopify/app-bridge-react
, refer to the React migration guide for framework-specific instructions.
Anchor to RequirementsRequirements
Anchor to Benefits of migrationBenefits of migration
When you migrate your app to use Shopify App Bridge, you can take advantage of the following improvements to the developer experience:
Anchor to Simplified configurationSimplified configuration
Shopify App Bridge simplifies the configuration process. Apps no longer need complex initialization or the host
config. Instead, they only need to provide their API key to the app-bridge.js
script.
Anchor to Automatic updatesAutomatic updates
The app-bridge.js
script automatically keeps itself up to date, so you can access new Shopify App Bridge APIs as soon as they're released.
Anchor to Use web standardsUse web standards
The latest version of Shopify App Bridge embraces the web platform and web standards, so you can use web APIs you're already familiar with. For more information about the motivation behind App Bridge, refer to Shopify's platform is the Web platform.
Anchor to Direct API accessDirect API access
Take advantage of the new Direct API access feature. You can make requests to the Admin API directly from your app using the standard web fetch API. For more information about Direct API access, refer to the documentation.
Anchor to Modals with custom contentModals with custom content
Add modals to your app with custom content using web components or React components from Shopify App Bridge. This enables you to create rich modal experiences that render directly in the Shopify admin. These modals are fast too, because they're preloaded.
Anchor to Step 1: Add the ,[object Object], script tagStep 1: Add the app-bridge.js
script tag
app-bridge.js
script tagInclude the app-bridge.js
script tag in your app. Replace %SHOPIFY_API_KEY%
with your app's client ID. This configures your app to use Shopify App Bridge.
The app-bridge.js
script is CDN-hosted, so your app always gets the latest version of it.
index.html
Anchor to Step 2: Upgrade your Shopify App Bridge dependencyStep 2: Upgrade your Shopify App Bridge dependency
Install or upgrade the Shopify App Bridge dependency for your framework with your package manager.
Terminal
npm
npm install @shopify/app-bridge@latest
Yarn
yarn add @shopify/app-bridge@latest
pnpm
pnpm add @shopify/app-bridge@latest
If you're using a framework-specific package like @shopify/app-bridge-react
, upgrade that package to the latest version as well.
Anchor to Step 3: Remove the initialization setupStep 3: Remove the initialization setup
In previous versions of App Bridge, you needed to manually initialize and configure App Bridge. This is no longer needed, as all the setup for Shopify App Bridge is done through the app-bridge.js
script tag that you added in step 1.
Remove all manual App Bridge initialization code from your app:
Initialization setup
3.x.x
Current
Anchor to Step 4: Update App Bridge APIsStep 4: Update App Bridge APIs
The following App Bridge APIs have been refactored or replaced. Review and update your code as described:
Anchor to ModalModal
The Modal API allows you to display an overlay that prevents interaction with the rest of the app until dismissed. Shopify App Bridge now uses Polaris web components: <s-modal>
for inline content and <s-app-window>
for modals with separate routes.
Anchor to Modal configuration changesModal configuration changes
The modal implementation has been simplified. Here are the key changes:
- Web component based: Modals now use
<s-modal>
for inline content or<s-app-window>
for src-based modals instead of imperative APIs. - Size configuration: Use the
size
attribute with values like 'small', 'large', or 'full-width'. - Title and content: Use the
heading
attribute for the modal title and add content as children. - Actions: Modal actions are handled through standard HTML buttons with
slot
attributes. - Auto-sizing: Modal auto-sizing is now automatic - no manual setup required.
Modal configuration
3.x.x
Current
Current (with src)
Anchor to Communication with the parent pageCommunication with the parent page
In previous versions, you needed to use the Modal.Action.DATA
action to communicate between the parent page and the modal.
For inline content modals: Since these render within your app's iframe, no special communication mechanism is needed - you can directly access your app's JavaScript context.
For src modals: Use the postMessage API to communicate with the parent page. Access postMessage
through window.opener
in the modal and through the modal's contentWindow
in the parent page.
Communication with src modals
3.x.x
Current
Current (modal page)
Anchor to TitleBarTitle Bar
The TitleBar API allows you to populate a standardized title bar with button actions and navigation breadcrumbs. Title bars are now configured using the <s-page>
component's title and action slots.
TitleBar configuration
3.x.x
Current
Breadcrumbs configuration
3.x.x
Current
The Navigation creates a navigation menu for your app. The navigation now uses the <s-app-nav>
Polaris web component.
Navigation configuration
3.x.x
Current
The active link is automatically matched based on the current URL.
Anchor to Other APIs that we've replacedOther APIs that we've replaced
All other App Bridge actions from previous versions have been replaced by new APIs provided through the shopify
global variable. Refer to the following table to learn about the API replacement:
Previous Action | New API |
---|---|
ContextualSaveBar | Contextual Save Bar API |
Loading | Loading API |
Picker | Picker API |
ResourcePicker | ResourcePicker API |
Toast | Toast API |
Features | Features API |
Cart | Cart API |
Client | Use the shopify global variable directly |
Anchor to Step 5: Update API usageStep 5: Update API usage
After migrating your imports and configuration, you'll need to update how you interact with App Bridge APIs. Most App Bridge functionality now uses the shopify
global variable for imperative APIs (like Toast, ResourcePicker) and web components for UI elements (like Modal, TitleBar).
Anchor to Accessing App Bridge APIsAccessing App Bridge APIs
The most significant change in Shopify App Bridge is how you access APIs. Instead of creating an app instance and dispatching actions, you now use web components for UI elements and the shopify
global variable for imperative APIs:
Accessing APIs
3.x.x
Current
Anchor to API replacementsAPI replacements
The following table shows how to replace previous App Bridge actions with new APIs:
Previous use | New API |
---|---|
app.getState() | Various APIs , for example shopify.user() for user info |
app.dispatch() | Direct method calls on shopify object |
app.subscribe() | Event listeners on specific APIs |
Authenticated fetch | Global fetch automatically includes auth headers |
History.Action.PUSH | shopify.navigation.navigate() |
Redirect.Action.APP | shopify.navigation.navigate() |
Redirect.Action.REMOTE | window.open() or window.location.href |
Anchor to Framework-specific considerationsFramework-specific considerations
If you're using a framework-specific package like @shopify/app-bridge-react
, refer to that package's migration guide for framework-specific updates. The core concepts remain the same:
- Remove manual initialization
- Access APIs through the
shopify
global variable - Use web standards where possible
- Let App Bridge handle authentication automatically