Loading...
Loading...
Guide for using Shopify App Bridge to embed apps in the Shopify Admin. Use this skill when the user needs to interact with the host interface (Admin), show toasts, modals, resource pickers, or handle navigation within a Shopify embedded app.
npx skill4agent add toilahuongg/shopify-agents-kit shopify-app-bridge[!NOTE] This skill focuses on Shopify App Bridge v3 (NPM package) and App Bridge CDN (v4) patterns. ALWAYS check which version the project is using. The latest standard is often typically App Bridge v4 (CDN-based /script) but many React apps still useoverview(v3/v4 wrapper).@shopify/app-bridge-react
shopify<script src="https://cdn.shopify.com/shopifycloud/app-bridge.js"></script>
<script>
shopify.config = {
apiKey: 'YOUR_API_KEY',
host: new URLSearchParams(location.search).get("host"),
forceRedirect: true,
};
</script>shopify[!TIP] Explore functionality:
- Open Chrome Developer Console in the Shopify Admin.
- Switch the frame context to your app's iframe.
- Type
to see all available methods and configurations.shopify
@shopify/app-bridge-reactimport { Provider } from '@shopify/app-bridge-react';
// ... configuration setupshopify.toast.show('Product saved');const modal = await shopify.modal.show({
title: 'My Modal',
message: 'Hello world',
footer: {
buttons: [
{ label: 'Ok', primary: true, id: 'ok-btn' }
]
}
});
modal.addEventListener('action', (event) => {
if (event.detail.id === 'ok-btn') {
modal.hide();
}
});const selected = await shopify.resourcePicker({
type: 'product', // 'product', 'variant', 'collection'
multiple: true,
});const selected = await shopify.resourcePicker({
type: 'product',
selectionIds: [
{ id: 'gid://shopify/Product/12345', variants: [{ id: 'gid://shopify/ProductVariant/67890' }] }
]
});const selected = await shopify.resourcePicker({
type: 'product',
filter: {
query: 'Sweater', // Initial search query
variants: false, // Hide variants
draft: false, // Hide draft products
}
});if (selected) {
console.log(selected);
// Returns array of selected resources
} else {
console.log('User cancelled picker');
}// Redirect to Admin Section
open('shopify:admin/products', '_top');
// Redirect to internal app route
open('shopify:app/my-route', '_top');shopify.saveBar.show();
shopify.saveBar.addEventListener('save', async () => {
// Perform save...
shopify.saveBar.hide();
shopify.toast.show('Saved');
});
shopify.saveBar.addEventListener('discard', () => {
shopify.saveBar.hide();
});[!IMPORTANT] Authentication: Ensure your app handles the OAuth flow and generates a session token. Requests to your backend MUST include the session token (Bearer token) if you rely on Shopify authentication. App Bridge handles fetching this token automatically in many configurations.
[!TIP] Navigation: When building a Remix app, use thehelpers to handle headers and bridging automatically where possible.@shopify/shopify-app-remix
[!WARNING] Host Parameter: Theparameter is CRITICAL for App Bridge to work. It must be present in the URL or passed to the config. It is a base64 encoded string provided by Shopify.host