Network Features
Admin UI extensions make it possible to surface contextual app functionality within the Shopify Admin interface.
Anchor to overviewOverview
Extend the Shopify Admin with UI Extensions.

Anchor to app-authenticationApp Authentication
Admin UI extensions can also make authenticated calls to your app's backend. When you use fetch()
to make a request to your app's configured auth domain or any of its subdomains, an Authorization
header is automatically added with a Shopify OpenID Connect ID Token. There's no need to manually manage ID tokens.
Relative URLs passed to fetch()
are resolved against your app's . This means if your app's backend is on the same domain as your
, you can make requests to it using
fetch('/path')
.
If you need to make requests to a different domain, you can use the method to retrieve the ID token and manually add it to your request headers.
Make requests to your app's backend
Examples
Make requests to your app's backend
Get Product Data
import {render} from 'preact'; import {useEffect, useState} from 'preact/hooks'; export default async () => { render(<Extension />, document.body); } // Get product info from app backend async function getProductInfo(id) { const res = await fetch(`/api/products/${id}`); return res.json(); } function Extension() { // Contextual "input" data passed to this extension: const {data} = shopify; const productId = data.selected?.[0]?.id; const [productInfo, setProductInfo] = useState(); useEffect(() => { getProductInfo(productId).then(setProductInfo); }, [productId]); return ( <s-admin-block title="Product Info"> <s-text>Info: {productInfo?.title}</s-text> </s-admin-block> ); }
Get Data from a different domain
import {render} from 'preact'; import {useEffect, useState} from 'preact/hooks'; export default async () => { render(<Extension />, document.body); } // Get product info from a different app backend async function getProductInfo(id, auth) { const token = await auth.idToken(); const res = await fetch(`https://app.example.com/api/products/${id}`, { headers: { Authorization: `Bearer ${token}`, }, }); return res.json(); } function Extension() { // Contextual "input" data passed to this extension: const {data, auth} = shopify; const productId = data.selected?.[0]?.id; const [productInfo, setProductInfo] = useState(); useEffect(() => { getProductInfo(productId, auth).then(setProductInfo); }, [productId, auth]); return ( <s-admin-block title="Product Info"> <s-text>Info: {productInfo?.title}</s-text> </s-admin-block> ); }
Anchor to direct-api-accessDirect API access
You can make Shopify Admin API requests directly from your extension using the query API or the standard web fetch API!
Any fetch()
calls from your extension to Shopify's Admin GraphQL API are automatically authenticated by default. These calls are fast too, because Shopify handles requests directly.
Direct API requests use online access mode by default. If you want to use offline access mode, you can set the property to
offline
in your app TOML file.
Note: Direct API can't be used to manage storefront access tokens.
Query Shopify data
Examples
Query Shopify data
Fetch Product data
import {render} from 'preact'; export default async () => { const productId = shopify.data.selected?.[0]?.id; const product = await getProduct(productId); render(<Extension product={product} />, document.body); }; async function getProduct(id) { const res = await fetch('shopify:admin/api/graphql.json', { method: 'POST', body: JSON.stringify({ query: ` query GetProduct($id: ID!) { product(id: $id) { title } } `, variables: {id}, }), }); const {data} = await res.json(); return data.product; } function Extension({product}) { return ( <s-admin-block heading="Product Info"> <s-text>The selected product title is {product.title}</s-text> </s-admin-block> ); }
Query Product data
import {render} from 'preact'; export default async () => { const productId = shopify.data.selected?.[0]?.id; const { data: {product}, } = await shopify.query( ` query GetProduct($id: ID!) { product(id: $id) { title } } `, {variables: {id: productId}}, ); render(<Extension product={product} />, document.body); }; function Extension({product}) { return ( <s-admin-block heading="Product Info"> <s-text>The selected product title is {product.title}</s-text> </s-admin-block> ); }
Anchor to custom-protocolsCustom Protocols
Custom protocols make it easier to navigate to common locations, and construct URLs.
Anchor to custom-protocols-shopify-protocolShopify Protocol
Use the shopify:admin
protocol when you want to construct a URL with a root of the Shopify Admin.
Anchor to custom-protocols-app-protocolApp Protocol
Use the app:
protocol to construct a URL for your app. Shopify will handle constructing the base URL for your app. This works for both embedded and non-embedded apps.
Anchor to custom-protocols-extension-protocolExtension Protocol
Triggers an action extension from a block extension using the extension:
protocol. The is the target of the action extension. The handle is the handle of the action extension that will be opened.
Anchor to custom-protocols-relative-urlsRelative Urls
Relative urls are relative to your app and are useful when you want to link to a route within your app. This works for both embedded and non-embedded apps.
Shopify:admin
Examples
shopify:admin
Link to Product Page
<s-link href="shopify:admin/products/1234567890">Link to Product Page</s-link>;
Fetch data
fetch('shopify:admin/api/graphql.json', { method: 'POST', body: JSON.stringify(simpleProductQuery), });
Anchor to securitySecurity
UI Extensions run on a different origin than the Shopify Admin. For network calls to succeed, your server must support cross-origin resource sharing (CORS) for the origin https://extensions.shopifycdn.com
.
If you have a custom Access-Control-Allow-Origin
header set, you must include https://extensions.shopifycdn.com
in the list of allowed origins.
If you are using the Shopify App Remix Template, this is done automatically for you.