How to get session token in shopify appbridge react v4

1 0 0
import createApp from "@shopify/app-bridge";
import { getSessionToken } from "@shopify/app-bridge/utilities";

const app = createApp({
  apiKey: "12345",

const sessionToken = await getSessionToken(app);

How can i get this session token in App Bridge React v4?

Replies 5 (5)

Shopify Partner
57 4 7

I'm having the same issue too after upgrading to v4 just to get the Modal working.



Shopify Partner
344 54 51


@Shopify/app-bridge/utilities package is deprecated

Instead of using this, You find everything on app state

App State

Once the app is set up, you can access additional details and the state of the app at any time by making async call app.getState():

app.getState().then((state) => {'App State:', state); });

Brain Station 23 PLC
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
Shopify Partner
57 4 7

Okay, so I can't install shopify/app-bridge and shopify/app-bridge-react without shopify/app-bridge-utils.


Here's what I have in my package.json.



Now I am getting a Module Not Found error:



Shopify Partner
57 4 7

I got it wrong. There's no @Shopify/app-bridge v4, that's for app-bridge-react. 

Shopify Partner
13 0 1

in app bridge react 4 with the app bridge JS tag added to your index.html you don't need that session token since all fetch calls are wrapped and add that token automatically however if you still need it you can use this :

where shopify is the variable u get this way : 
const shopify = useAppBridge()