Pass Shopify AppBridge instance to various Nuxt / Vue components

Viewed 274

I'm trying to initialize a Shopify AppBridge instance (https://shopify.dev/tools/app-bridge) one time per store (user), and then use that same instance throughout my app to use the various AppBridge features.

My original idea was to add the AppBridge instance into a Vuex store; but I am unable to call any functions within the AppBridge object when retrieving it from the store (something to do with it being a serialized object?). There are various functions I need to use within the instance/object; so this won't work.

So, what is the best way for me to do the following:

  1. App loads
  2. Middleware or function runs, initializing AppBridge with the user's / store's details
  3. Other pages are loaded, use the same AppBridge instance for various features

My current setup is that I re-create a new AppBridge instance on every page / component, but that causes complications.

Any ideas? Much appreciated!

0 Answers
Related