Shopify App Bridge not working in react app

Shopify App Bridge not working in react app

Mayank
Shopify Partner
1 0 5

I have created a react app for shopify admin and want to use shopify's style system. For that I have installed the latest versions of "@shopify/polaris" and "@Shopify/app-bridge-react" and followed the steps provided for setup. The polaris library is working fine but app-bridge is giving me problems.

For app bridge setup:

1. I have installed 

"@shopify/app-bridge-react": "^4.1.3"

2. Added this script in the head of my index.html:

<meta name="shopify-api-key" content="%SHOPIFY_API_KEY%" />
<script src="https://cdn.shopify.com/shopifycloud/app-bridge.js"></script>
 
But when I import and use anything from @Shopify/app-bridge-react it doesn't work and gives me this error:
Uncaught Error: App Bridge Next: missing required configuration fields: shop
    at app-bridge.js:1:44135
    at app-bridge.js:1:44212
    at app-bridge.js:1:44242
    at app-bridge.js:1:53002
    at app-bridge.js:1:60155

Can anyone please help me resolve this issue ?

Replies 8 (8)

junejuly1
Shopify Partner
2 0 1

Same here, using vite

ohtasoji
Visitor
1 0 0

same issue with vite, did you ever figure this out?

iffikhan30
Shopify Partner
291 37 54

Hello Found this solution you can add like this

Custom theme and app [remix] expert.

Email: irfan.sarwar.khan30@gmail.com
Chat on WhatsApp
Mazz
Shopify Partner
7 0 0

I still have the same issue.

 

<script src="https://cdn.shopify.com/shopifycloud/app-bridge.js?apiKey=<--API_KEY_-->"></script>

 

Did not work for me.
I added the shop URL to the query params to fix the issue.

iffikhan30
Shopify Partner
291 37 54

share some more detail about your app

which platform you created

where your application deploy
and more...

Custom theme and app [remix] expert.

Email: irfan.sarwar.khan30@gmail.com
Chat on WhatsApp

jam_chan
Shopify Partner
932 23 192

The Same. Using Vite too. Why does the App Bridge doc not mention the shop parameter is required?

BYOB - Build Your Own Bundles, SPO - SEO App to research keywords & edit social link preview

Hemal
Shopify Partner
5 0 0
Hi Mayank & All,

To resolve this issue, you will need to include the following meta tags in your HTML, specifying the `shop` and `api-key` as shown below:
 
<!-- Shopify App Bridge [START] -->
<meta name="shopify-api-key" content="SHOPIFY_API_KEY" />
<meta name="shopify-shop" content="shop.myshopify.com" />
<!-- Shopify App Bridge [END] -->

All the best.
Simply Programmer
eriksmiks
Shopify Partner
1 0 0

This worked! Thank you so much! Spent full day and 50+ tries to get the app bridge working. Whatever the app bridge next is there is no documentation online besides couple sentences. Did not help that I had not configured correct domain in my shopify.app.toml nad it kept resetting the urls input through app settings in partner dashboard.