A developer is attempting to integrate Shopify App Bridge into Storybook for UI component development, specifically to test modal implementations. They’re using Vite for local development and have added the App Bridge script to preview-head.html.
Using App Bridge React v4.1.3, Polaris v13.9.0, and Storybook v8.2.7
Need to use App Bridge modals because Polaris modal component is officially discouraged
Components use useAppBridge() hook and Modal from @shopify/app-bridge-react
Storybook configured with AppProvider decorator wrapping stories
Community Response:
One commenter questioned whether App Bridge can function outside the Shopify admin environment, suggesting abstractions or placeholder data as alternatives. The original poster clarified their specific need for modal testing.
Current Status:
The discussion remains unresolved, with another user asking for updates on whether a solution was found or if it’s impossible to achieve.
Summarized with AI on October 24.
AI used: claude-sonnet-4-5-20250929.
I’m currently working on a Shopify app and using Vite for my local development environment. I want to integrate Shopify App Bridge into Storybook for UI component development. I have added the following code to my preview-head.html:
The versions of the dependencies and devDependencies I am using are:
Error: App Bridge Next: missing required configuration fields: shop
Error: The shopify global is not defined. This likely means the App Bridge script tag was not added correctly to this page
Has anyone successfully set up Shopify App Bridge in Storybook, and could you share any tips or code examples on how to achieve this? Specifically, I am looking for guidance on:
Initializing App Bridge within Storybook’s environment.
Ensuring that the app bridge context is correctly passed to all components.
Any advice or examples would be greatly appreciated!
The reason I want to use App Bridge within Storybook is to ensure that the various contents implemented in the modal are working correctly. While it is possible to use the modal component from Polaris, it is officially discouraged, so I need to use the App Bridge modal.
The code I am implementing is very simple. In addition to the “preview-head.html” I mentioned earlier, I am calling the following within the necessary components: