Shopify App version 18.0.2 and App Bridge

HunkyBill
Shopify Expert
4845 60 547

App Bridge 2.0 now requires a host parameter. So a bunch of my old codes now puke and die without it. 

Looking at the Shopify App code, the login protection comes with a host method, and returns a host parameter if provided.

How can I get access to this host parameter as a nice consistent value throughout my App where I need it? In my embedded app layout, I have access to my Shopify App API key, the shop domain, but not the new host parameter.

What is the secret sauce to ensuring this is set?

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
Replies 2 (2)

ElanaK
Shopify Staff
15 4 4

Hello 👋

The host should be available in the URL params when loading your app, so you should be able to grab it with something like this:

const host = new URLSearchParams(window.location.search).get('host')

 

We recommend reusing the same App Bridge instance throughout your app since the host is only guaranteed on initial load of your app.

Please let me know if this doesn't work for you!

Elana

 

To learn more visit the Shopify Help Center or the Community Blog.

HunkyBill
Shopify Expert
4845 60 547

Nope, that is not useful. That would be fine for front-end work, and while you are correct that the Shopify React Polaris machine comes to life on the front-end, I need the host parameter in the back end, and my question was more geared towards that. I have the answer now, and yes, it does involve saving the parameter and instantiating a session to hold it.

I will comment further, that the more Shopify digs these holes for itself, the quicker all the crowd will be to disperse into the netherworlds, not to be seen or heard from again. You may call it progress, but we call it PITA every time someone at Shopify invents a new way to tick everyone off with fluff.

In other words, if Shopify is going to impose fluff on us, do us a solid and explain why you're doing, what the fluff is good for, how you intend to change fluff over time, and how long you think fluff will even last. We got none of that with fluffy host.

 

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com