How can I refresh the parent window inside Shopify App Bridge?

Hi, I am trying to implement a auth strategy where I need to refresh the Shopify admin page after signup and login. Is this possible inside the Shopify app-bridge?

Hello @Paul122

Try this below the steps - it will be helpful for you:
i) Import bridge action
e.g.

import {Redirect} from ‘@shopify/app-bridge/actions’;

ii) initialize variable
e.g.

const app = useAppBridge();
const redirect = Redirect.create(app);

iii) Redirect on top frame
e.g

redirect.dispatch(Redirect.Action.ADMIN_PATH, {
path: ${apps_url},
newContext: false,
});

I tried :

import {Redirect} from '@shopify/app-bridge/actions';
import {useAppBridge} from "@shopify/app-bridge-react";
const apps_url = "https://4d48-2003-c9-3f2b-3da7-8192-ff97-ed82-a6f6.eu.ngrok.io";
const app = useAppBridge();
const redirect = Redirect.create(app);
redirect.dispatch(Redirect.Action.ADMIN_PATH, {
  path: `${apps_url}`,
  newContext: false,
});

And it didnt worked, what am I missing ?

Hello @Paul122

Given solution definitely reload shopify admin page, Problem might be on logic where you identify login or signup.

Please check your code flow…

Sorry, I didn’t mean to Say your Code doesn’t work. What I’m trying to say the way I implemented your suggestion Inside my React code doesn’t get executed the right way because I get an Error:

TypeError: Cannot read properties of null (reading 'context')

inside the browser console.

My codeflow works perfectly fine when I reload the page manually per hand.