Shopify.navigation.navigate broken?

Hey all,

the redirect for my embedded apps has stopped working in the last day or so.

Temporary fix was to replace it with a simple window top location href:

window.top.location.href = url;
//await window.shopify.navigation.navigate(url);

It is, of course, annoying, as my users couldn’t use the app.
What’s the solution for this?

I’d say I have a pretty much standard setup, an embedded app.

Thanks,
Peter

1 Like

Hi @perice ,

We shipped a fix for this earlier this morning! Can you confirm if it is still a problem?

Hey @Elana ,

not working for me, this code:

await shopify.navigation.navigate(url);

throws:

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading ‘navigate’)
at Object.navigate
at Object.redirectToAdmin

Claude suggested this, and this works:

const parsed = new URL(url, location.href);

if(window.top !== window)
{
open(parsed.pathname + parsed.search + parsed.hash, ‘_self’);
} else
{
window.location.href = url;
}

Are you sure window.shopify.navigation.navigate ever works? `window.open(url, ‘_top‘)`

It worked, and it’s also documented here:

Our docs actually had an error in them. I’ve updated them now. I’m not sure how that was working before since we haven’t supported that API. Very sorry for the confusion!