App state
You can access the app state using a React hook.
The useAppBridgeState
hook supports accessing all or parts of the application state, including keys like context
, features
, and staffMember
. For more information about options, refer to Props.
Anchor to Example codeExample code
Note
When using the App Bridge React library, you need to wrap all of your App Bridge React code inside of a single App Bridge Provider
.
Get the entire app state with no arguments.
import {useAppBridgeState} from '@shopify/app-bridge-react';
function MyComponent {
const appState = useAppBridgeState();
...
}
Get a specific piece of the app state with an argument.
import {useAppBridgeState} from '@shopify/app-bridge-react';
function MyComponent {
const staffMember = useAppBridgeState('staffMember');
...
}
Anchor to PropsProps
Name | Type | Description | Required |
---|---|---|---|
state | "cart" , "client" , "context" , "contextualSaveBar" , "features" , "fullscreen" , "isLegacy" , "loading" , "menu" , "modal" , "navigation" , "pos" , "print" , "resourcePicker" , "scanner" , "sessionToken" , "share" , "staffMember" , "titleBar" , "toast" | Key in app state to access | No |
Was this page helpful?