Skip to content

Instantly share code, notes, and snippets.

@hassanrazadev
Created October 20, 2023 15:47
Show Gist options
  • Save hassanrazadev/2b7b819e10331c539b25bfb1f40d72f7 to your computer and use it in GitHub Desktop.
Save hassanrazadev/2b7b819e10331c539b25bfb1f40d72f7 to your computer and use it in GitHub Desktop.
Reload Shopify embbeded app from ifram using App Bridge
// <script src="https://cdn.jsdelivr.net/npm/@shopify/app-bridge@3.7.9/umd/index.min.js"></script>
const AppBridge = window['app-bridge'];
const createApp = AppBridge.default;
const Redirect = AppBridge.actions.Redirect;
const shopifyApp = createApp({
apiKey: "api_key",
host: new URLSearchParams(document.referrer).get("host"),
forceRedirect: true
});
const redirect = Redirect.create(shopifyApp);
// fnially, reload the main page
redirect.dispatch(Redirect.Action.REMOTE, document.referrer);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment