How to get session token in shopify appbridge react v4

Topic summary

Developers are seeking guidance on obtaining session tokens after upgrading to Shopify App Bridge React v4, as the previous method using @shopify/app-bridge/utilities and getSessionToken() is now deprecated.

Key Solutions Identified:

  • The @shopify/app-bridge-utils package is deprecated; developers should use the main @shopify/app-bridge package instead
  • Access app details via app.getState() async call for state information
  • In App Bridge React v4, fetch calls automatically include the session token when the App Bridge JS tag is added to index.html

Current Approach:

For cases requiring explicit token access:

  • Use const shopify = useAppBridge() hook
  • Call await shopify.idToken() to retrieve the authentication token
  • Reference the ID Token API documentation for implementation details

Outstanding Issues:

  • One developer reports tokens expire quickly and seeks a refresh mechanism
  • Another encounters API authentication errors despite implementing the solution
  • Some confusion exists around version compatibility between @shopify/app-bridge and @shopify/app-bridge-react
Summarized with AI on November 2. AI used: claude-sonnet-4-5-20250929.

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 :
https://shopify.dev/docs/api/app-bridge-library/apis/id-token

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

1 Like