shopify-app-bridge
Shopify App Bridge Skill
Shopify App Bridge is a library that allows you to embed your app directly inside the Shopify Admin. It provides a way to communicate with the host environment to trigger actions and navigation.
[!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 /
overviewscript) but many React apps still use@shopify/app-bridge-react(v3/v4 wrapper).
Core Concepts
- Host: The Shopify Admin (web or mobile).
- Client: Your embedded app.
- Actions: Messages sent to the host to trigger UI elements (Toast, Modal) or navigation.
Setup & Initialization
Using CDN (App Bridge v4 - Recommended)
In modern Shopify apps, the preferred method is using the CDN script. This automatically exposes the shopify global variable, which is the primary entry point for all actions.
<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>
debugging & Exploration
Once initialized, the shopify global variable is available in your browser console.
[!TIP] Explore functionality:
- Open Chrome Developer Console in the Shopify Admin.
- Switch the frame context to your app's iframe.
- Type
shopifyto see all available methods and configurations.
Using @shopify/app-bridge-react (Legacy/Specific Use Cases)
If you are strictly using React components or need the Provider context for deeply nested legacy components:
import { Provider } from '@shopify/app-bridge-react';
// ... configuration setup
Common Actions
Toast
Display a temporary success or error message.
shopify.toast.show('Product saved');
Modal
Open a modal dialog.
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();
}
});
Resource Picker
Select products, collections, or variants.
Simple Selection
const selected = await shopify.resourcePicker({
type: 'product', // 'product', 'variant', 'collection'
multiple: true,
});
Pre-selected Resources Useful for editing existing selections.
const selected = await shopify.resourcePicker({
type: 'product',
selectionIds: [
{ id: 'gid://shopify/Product/12345', variants: [{ id: 'gid://shopify/ProductVariant/67890' }] }
]
});
Filtered Selection Filter by query or status.
const selected = await shopify.resourcePicker({
type: 'product',
filter: {
query: 'Sweater', // Initial search query
variants: false, // Hide variants
draft: false, // Hide draft products
}
});
Handling Selection
if (selected) {
console.log(selected);
// Returns array of selected resources
} else {
console.log('User cancelled picker');
}
Navigation / Redirect
Navigate within the Shopify Admin.
// Redirect to Admin Section
open('shopify:admin/products', '_top');
// Redirect to internal app route
open('shopify:app/my-route', '_top');
Contextual Save Bar
Show a save bar when the user has unsaved changes.
shopify.saveBar.show();
shopify.saveBar.addEventListener('save', async () => {
// Perform save...
shopify.saveBar.hide();
shopify.toast.show('Saved');
});
shopify.saveBar.addEventListener('discard', () => {
shopify.saveBar.hide();
});
Best Practices
[!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 the
@shopify/shopify-app-remixhelpers to handle headers and bridging automatically where possible.
[!WARNING] Host Parameter: The
hostparameter 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.
References
More from toilahuongg/shopify-agents-kit
shopify-polaris-icons
Guide for using Shopify Polaris Icons in Shopify Apps. Covers icon usage patterns, accessibility, tone variants, and common icon categories for commerce applications.
19email-template-design
Design and build professional HTML email templates with inline CSS for broad email client compatibility. Use this skill when the user asks to create, design, or build email templates, newsletters, transactional emails (order confirmations, receipts, shipping notifications, password resets), marketing emails, welcome series, onboarding emails, abandoned cart emails, drip campaigns, or any HTML email layout. Covers responsive design, dark mode support, and compatibility with Gmail, Outlook (desktop + web), Apple Mail, Yahoo, and mobile clients.
18shopify-extensions
Guide for building and managing Shopify Extensions (Admin, Checkout, Theme, Post-purchase, etc.) using the latest Shopify CLI and APIs.
14shopify-api
Comprehensive guide for Shopify APIs in Remix apps. Covers Admin GraphQL/REST, Storefront API, all resources (products, orders, customers, inventory, collections, discounts, fulfillments, metafields, files), bulk operations, webhooks, resource pickers, and TypeScript patterns. Use when querying/mutating Shopify data or building integrations.
14shopify-polaris-viz
Guide for creating data visualizations in Shopify Apps using the Polaris Viz library. Use this skill when building charts, graphs, dashboards, or any data visualization components that need to integrate with the Shopify Admin aesthetic. Covers BarChart, LineChart, DonutChart, SparkLineChart, and theming.
13code-investigator
Comprehensive code investigation and audit tool. Discovers all project features, then dispatches parallel subagents to analyze issues, risks, dead code, missing functionality, and redundancies. Produces a prioritized risk report. Use this skill when the user asks to "investigate code", "audit project", "find risks", "check code quality", "analyze codebase", "what's wrong with this code", "project health check", "code review entire project", "find dead code", "find redundant code", or any request for a thorough codebase analysis.
11