Skip to main content

useAppBridge

Info

App Bridge isn't versioned with Polaris. App Bridge APIs and web components are identical in every App Home reference version.

The useAppBridge hook returns the shopify global variable to use App Bridge APIs such as toast and resourcePicker.

  • React integration: Access the shopify global in React components to use App Bridge APIs like toast and resource picker.
  • Server rendering: Safely access App Bridge during server-side rendering where the shopify global isn't available.
  • API access: Use the returned shopify object to call any App Bridge API from within a React component.
  • Framework compatibility: Integrate App Bridge with React-based frameworks like React Router or Remix.

The useAppBridge hook is available for use in your app. It returns the shopify global or a proxy when not in a browser environment.

For more information, see the global variable section and the individual reference pages like Toast and Resource Picker.

export interface {}
Examples

tsx

import {useAppBridge} from '@shopify/app-bridge-react';

export function GenerateBlogPostButton() {
const shopify = useAppBridge();

function generateBlogPost() {
// Handle generating
shopify.toast.show('Blog post template generated');
}

return <button onClick={generateBlogPost}>Generate Blog Post</button>;
}


Was this page helpful?