Gathering detailed insights and metrics for @gadgetinc/react-shopify-app-bridge
Gathering detailed insights and metrics for @gadgetinc/react-shopify-app-bridge
Gathering detailed insights and metrics for @gadgetinc/react-shopify-app-bridge
Gathering detailed insights and metrics for @gadgetinc/react-shopify-app-bridge
Monorepo for the core JavaScript / TypeScript client code and bindings to frontend libraries
npm install @gadgetinc/react-shopify-app-bridge
Typescript
Module System
Node Version
NPM Version
TypeScript (90.67%)
HTML (7.68%)
JavaScript (1.5%)
CSS (0.12%)
Nix (0.02%)
Shell (0.01%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
11 Stars
1,998 Commits
8 Forks
6 Watchers
127 Branches
25 Contributors
Updated on Jul 10, 2025
Latest Version
0.18.6
Package Id
@gadgetinc/react-shopify-app-bridge@0.18.6
Unpacked Size
95.79 kB
Size
16.00 kB
File Count
22
NPM Version
10.2.4
Node Version
18.19.1
Published on
Jul 02, 2025
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
3
4
This library implements the following features:
@gadgetinc/react
This is a companion package to the JavaScript client package generated for your Gadget app. You must first install the JS client for your app, and then install this package.
To install the JS client for your app, you must set up the Gadget NPM registry, and then install the client:
1npm config set @gadget-client:registry https://registry.gadget.dev/npm 2 3yarn add @gadget-client/my-app-slug 4# or 5npm install @gadget-client/my-app-slug
Full installation instructions can be found in the Gadget docs at https://docs.gadget.dev/api/<my-app-slug>/external-api-calls/installing
.
Once you have your JS client installed, you can install the React hooks library and the Shopify App bridge library with yarn
or npm
:
yarn add @gadgetinc/react-shopify-app-bridge @gadgetinc/react @shopify/app-bridge-react react
# or
npm install --save @gadgetinc/react-shopify-app-bridge @gadgetinc/react @shopify/app-bridge-react react
While exploring Shopify embedded app development, you may have come across documentation on how to set up Shopify App Bridge. This package will take care of all steps involving OAuth and initializing the Shopify app bridge. The OAuth steps as well as initializing the Shopify app bridge is handled by the Provider
. The initialized instance of App Bridge is accessible via the appBridge
key returned from useGadget
.
NOTE: This example is very similar to that found in @gadgetinc/react, however, this example should be followed if you're using the @gadgetinc/react-shopify-app-bridge
package.
src/api.ts
1// replace `my-app-slug` with your app slug from your Gadget app's domain 2import { Client, BrowserSessionStorageType } from "@gadget-client/my-app-slug"; 3 4export const api = new Client({ 5 authenticationMode: { 6 browserSession: { 7 storageType: BrowserSessionStorageType.Temporary, 8 }, 9 }, 10});
src/app.tsx
1// import Gadget's react hooks for accessing data from your Gadget app 2import { useAction, useFindMany } from "@gadgetinc/react"; 3// import the Gadget<->Shopify bindings that manage the auth process with Shopify 4import { AppType, Provider as GadgetProvider, useGadget } from "@gadgetinc/react-shopify-app-bridge"; 5// import and use Shopify's react components like you might in other Shopify app 6import { Button, Redirect, TitleBar } from "@shopify/app-bridge/actions"; 7// import the instance of the Gadget API client for this app constructed in the other file 8import { api } from "./api"; 9 10export default function App() { 11 return ( 12 // Wrap our main application's react components in the `<GadgetProvider/>` component to interface with Shopify 13 // This wrapper sets up the Shopify App Bridge, and will automatically redirect to perform the OAuth authentication if the shopify shop doesn't yet have the store installed. 14 <GadgetProvider type={AppType.Embedded} shopifyApiKey="REPLACE ME with api key from Shopify partners dashboard" api={api}> 15 <ProductManager /> 16 </GadgetProvider> 17 ); 18} 19 20// An example component that uses the Gadget React hooks to work with data in the Shopify backend 21function ProductManager() { 22 const { loading, appBridge, isRootFrameRequest, isAuthenticated } = useGadget(); 23 const [, deleteProduct] = useAction(api.shopifyProduct.delete); 24 const [{ data, fetching, error }, refresh] = useFindMany(api.shopifyProduct); 25 26 if (error) return <>Error: {error.toString()}</>; 27 if (fetching) return <>Fetching...</>; 28 if (!data) return <>No products found</>; 29 30 // Set up a title bar for my embedded app 31 const breadcrumb = Button.create(appBridge, { label: "My breadcrumb" }); 32 breadcrumb.subscribe(Button.Action.CLICK, () => { 33 appBridge.dispatch(Redirect.toApp({ path: "/breadcrumb-link" })); 34 }); 35 36 const titleBarOptions = { 37 title: "My page title", 38 breadcrumbs: breadcrumb, 39 }; 40 TitleBar.create(appBridge, titleBarOptions); 41 42 return ( 43 <> 44 {loading && <span>Loading...</span>} 45 {/* A user is viewing this page from a direct link so show them the home page! */} 46 {!loading && isRootFrameRequest && <div>Welcome to my cool app's webpage!</div>} 47 {!loading && 48 isAuthenticated && 49 data.map((product) => ( 50 <button 51 onClick={(event) => { 52 event.preventDefault(); 53 void deleteProduct({ id: product.id }).then(() => refresh()); 54 }} 55 > 56 Delete {product.name} 57 </button> 58 ))} 59 </> 60 ); 61}
@shopify/app-bridge-react
allows you to specify a custom router configuration to manage client-side routing. Similarly, the Gadget provider will allow you to specify a custom router which will be forwarded to the App Bridge.
1// import Gadget's react hooks for accessing data from your Gadget app 2// import the Gadget<->Shopify bindings that manage the auth process with Shopify 3import { AppType, Provider as GadgetProvider } from "@gadgetinc/react-shopify-app-bridge"; 4// import and use Shopify's react components like you might in other Shopify app 5import { useMemo } from "react"; 6// import the instance of the Gadget API client for this app constructed in the other file 7import { BrowserRouter, useLocation, useNavigate } from "react-router-dom"; 8import { api } from "./api"; 9// import your app's custom routes 10import Routes from "./Routes"; 11 12function App() { 13 const navigate = useNavigate(); 14 const location = useLocation(); 15 const history = useMemo(() => ({ replace: (path) => navigate(path, { replace: true }) }), [navigate]); 16 17 const router = useMemo( 18 () => ({ 19 location, 20 history, 21 }), 22 [location, history] 23 ); 24 25 return ( 26 // Wrap our main application's react components in the `<GadgetProvider/>` component to interface with Shopify 27 // This wrapper sets up the Shopify App Bridge, and will automatically redirect to perform the OAuth authentication if the shopify shop doesn't yet have the store installed. 28 <GadgetProvider 29 type={AppType.Embedded} 30 shopifyApiKey="REPLACE ME with api key from Shopify partners dashboard" 31 api={api} 32 router={router} 33 > 34 <Routes /> 35 </GadgetProvider> 36 ); 37} 38 39export default function AppWrapper() { 40 return ( 41 <BrowserRouter> 42 <App /> 43 </BrowserRouter> 44 ); 45}
No vulnerabilities found.
No security vulnerabilities found.