### Checkout UI Extension Configuration Example
Source: https://shopify.dev/docs/api/customer-account-ui-extensions/latest/configuration
Example TOML file demonstrating configuration settings for a checkout UI extension.
```toml
# Example TOML file for a checkout UI extension
[settings.shipping_address.fields.first_name]
type = "single_line_text_field"
label = "First name"
[settings.shipping_address.fields.last_name]
type = "single_line_text_field"
label = "Last name"
[settings.shipping_address.fields.phone]
type = "single_line_text_field"
label = "Phone number"
validation = {
name = "regex"
value = "^\\+?[1-9]\\d{1,14}$"
}
[settings.shipping_address.fields.country]
type = "single_line_text_field"
label = "Country"
validation = {
name = "choices"
value = '["USA", "Canada", "Mexico"]'
}
[settings.shipping_address.fields.zip_code]
type = "single_line_text_field"
label = "ZIP code"
validation = {
name = "min"
value = "5"
}
[settings.shipping_address.fields.notes]
type = "multi_line_text_field"
label = "Notes"
validation = {
name = "max"
value = "500"
}
[settings.delivery_date]
type = "date"
label = "Delivery date"
validation = {
name = "min"
value = "2023-01-01"
}
[settings.delivery_time]
type = "date_time"
label = "Delivery time"
validation = {
name = "min"
value = "2023-01-01T09:00:00"
}
[settings.quantity]
type = "number_integer"
label = "Quantity"
validation = {
name = "min"
value = "1"
}
[settings.discount]
type = "number_decimal"
label = "Discount"
validation = {
name = "max_precision"
value = "2"
}
```
--------------------------------
### Stack Component Example
Source: https://shopify.dev/docs/api/customer-account-ui-extensions/latest/web-components/layout-and-structure/stack
Demonstrates basic usage of the Stack component for vertical arrangement of elements with spacing.
```javascript
import { Stack, Text } from '@shopify/ui-extensions/customer-account';
export default function MyComponent() {
return (
First item
Second item
Third item
);
}
```
--------------------------------
### Chip with Icon Example
Source: https://shopify.dev/docs/api/customer-account-ui-extensions/latest/web-components/actions/clickable-chip
Adds a graphic, such as an icon, to the start of the chip to visually reinforce its label. Use the `graphic` slot for this purpose.
```html
On sale
```
--------------------------------
### Basic Tooltip Usage
Source: https://shopify.dev/docs/api/customer-account-ui-extensions/latest/web-components/overlays/tooltip
Demonstrates how to use tooltips with clickable elements to provide additional context. This example shows tooltips for tracking and help icons.
```html
Track your order
Get help with this order
```
--------------------------------
### Stack with Wrap
Source: https://shopify.dev/docs/api/customer-account-ui-extensions/latest/web-components/layout-and-structure/stack
Example of enabling wrapping for Stack items when they exceed available space.
```javascript
import { Stack, Text } from '@shopify/ui-extensions/customer-account';
export default function MyComponent() {
return (
Item 1
Item 2
Item 3
Item 4
Item 5
);
}
```
--------------------------------
### Select with placeholder text
Source: https://shopify.dev/docs/api/customer-account-ui-extensions/latest/web-components/forms/select
Shows a dropdown with hint text to prompt the customer for a selection. This example uses a placeholder for language selection.
```html
English
French
Spanish
German
```
--------------------------------
### Collect a website URL
Source: https://shopify.dev/docs/api/customer-account-ui-extensions/latest/web-components/forms/url-field
Add a URL input with a pre-filled value. This example shows a URL field with a label and value.
```html
```
--------------------------------
### Display a QR code
Source: https://shopify.dev/docs/api/customer-account-ui-extensions/latest/web-components/media-and-visuals/qr-code
Render a scannable QR code from a URL. This example encodes a link that customers can scan with their smartphone to visit the destination.
```html
```
--------------------------------
### Display a labeled loading state
Source: https://shopify.dev/docs/api/customer-account-ui-extensions/latest/web-components/feedback-and-status-indicators/spinner
Pair a spinner with text to describe what's loading. This example centers a spinner above a descriptive message.
```html
Loading order details...
```
--------------------------------
### Basic section with content
Source: https://shopify.dev/docs/api/customer-account-ui-extensions/latest/web-components/layout-and-structure/section
Use a section to wrap related content under a descriptive heading. This example shows a rewards section with descriptive text and action buttons.
```html
Earn 10 points for every $1 spent. Redeem 100 points for $10 off your next purchase
Redeem
My rewards
```
--------------------------------
### Create a Collapsible Section
Source: https://shopify.dev/docs/api/customer-account-ui-extensions/latest/web-components/typography-and-content/details
Use s-details and s-summary to hide supplementary content until the customer chooses to expand it. This example wraps pickup instructions.
```html
Pickup instructions
Curbside pickup is at the back of the warehouse. Park in a stall and follow the signs.
```
--------------------------------
### Confirming Destructive Actions
Source: https://shopify.dev/docs/api/customer-account-ui-extensions/latest/web-components/overlays/modal
This example demonstrates how to use a modal to confirm a destructive action, such as canceling a subscription. It pairs a cancel button with a critical-toned action button.
```html
Cancel subscription
This will cancel your subscription immediately. You'll lose access to
all benefits at the end of your current billing period.
Keep subscription
Cancel subscription
```
--------------------------------
### Using Icons in Badges
Source: https://shopify.dev/docs/api/customer-account-ui-extensions/latest/web-components/media-and-visuals/icon
Shows how to associate icons with badge components to visually represent status. This example includes neutral and critical badges with corresponding icons.
```html
Delivered
Action needed
```
--------------------------------
### Initiate Return with Login Check
Source: https://shopify.dev/docs/api/customer-account-ui-extensions/latest/target-apis/account-apis/require-login-api
This example shows how to initiate a return after ensuring the buyer is logged in. It first checks the authentication state and only calls `shopify.requireLogin()` if the buyer is not yet fully authenticated.
```jsx
import '@shopify/ui-extensions/preact';
import {render} from 'preact';
import {useState} from 'preact/hooks';
export default async () => {
render(, document.body);
};
function Extension() {
const [submitted, setSubmitted] =
useState(false);
async function initiateReturn() {
await shopify.requireLogin();
const authState =
shopify.authenticationState.value;
if (authState !== 'fully_authenticated') {
return;
}
setSubmitted(true);
}
if (submitted) {
return (
Your return request has been submitted.
We will send a confirmation email shortly.
);
}
return (
Need to return an item?
You will be asked to log in before
submitting a return request.
Start a return
);
}
```
--------------------------------
### Deep-link to Another Extension
Source: https://shopify.dev/docs/api/customer-account-ui-extensions/latest/target-apis/platform-apis/navigation-api
Deep-links to a different installed extension using the 'extension://' protocol. This example navigates to a loyalty rewards extension.
```jsx
import '@shopify/ui-extensions/preact';
import {render} from 'preact';
export default async () => {
render(, document.body);
};
function Extension() {
function handleNavigate() {
shopify.navigation.navigate(
'extension://loyalty-rewards',
);
}
return (
You have 1,200 points available.
View rewards
);
}
```
--------------------------------
### Programmatically Hide a Toast
Source: https://shopify.dev/docs/api/customer-account-ui-extensions/latest/target-apis/platform-apis/toast-api
This example shows how to get a handle to a toast notification and dismiss it programmatically using the `hide()` method. This is useful for custom dismissal logic.
```javascript
import { showToast } from '@shopify/customer-account-ui-extensions/toast';
const toastHandle = await showToast('Processing your request...');
// To dismiss the toast programmatically:
// toastHandle.hide();
```
--------------------------------
### Use responsive images
Source: https://shopify.dev/docs/api/customer-account-ui-extensions/latest/web-components/media-and-visuals/image
Set up responsive image sources using `srcSet` and `sizes`. This example configures the browser to select appropriate image sources based on viewport width.
```html
```
--------------------------------
### Show Range Validation Error
Source: https://shopify.dev/docs/api/customer-account-ui-extensions/latest/web-components/forms/number-field
Display an error message when the input value exceeds the allowed range. This example configures a number field with `min`, `max`, and an `error` message to guide the user.
```html
```
--------------------------------
### Navigate to an Extension Route
Source: https://shopify.dev/docs/api/customer-account-ui-extensions/latest/target-apis/platform-apis/navigation-api
This example demonstrates how to navigate to a specific route within the current extension using the `extension://` protocol. It renders a button that, when clicked, triggers navigation to the 'orders' path.
```jsx
import '@shopify/ui-extensions/preact';
import {render} from 'preact';
export default async () => {
render(, document.body);
};
function Extension() {
return (
{
shopify.navigation.navigate('extension://orders');
}}
>
Navigate to orders path
);
}
```
--------------------------------
### Get customer's country and display region-specific message
Source: https://shopify.dev/docs/api/customer-account-ui-extensions/latest/target-apis/platform-apis/localization-api
Read the customer's country to conditionally render region-specific messaging. This example checks if the customer is in Canada and displays a warning if so. Guard against missing localization data as these values load asynchronously.
```jsx
import '@shopify/ui-extensions/preact';
import {render} from 'preact';
export default async () => {
render(, document.body);
};
function Extension() {
const countryCode =
shopify.localization?.country?.value?.isoCode;
if (countryCode === 'CA') {
return (
{shopify.i18n.translate(
'canadaPostWarningMessage',
)}
);
}
}
```
```json
{
"canadaPostWarningMessage": "Canada Post has issued a red delivery service alert for Ontario due to a severe snowstorm, suspending package delivery and collection for the week."
}
```
--------------------------------
### Display Related Products in Order Status Extension
Source: https://shopify.dev/docs/api/customer-account-ui-extensions/latest/targets/order-status
This example fetches product recommendations from your app's backend using the session token for authentication and displays them as a list below the line item list. It requires a backend endpoint at 'https://your-app.com/api/recommendations' to provide product data.
```jsx
import '@shopify/ui-extensions/preact';
import {render} from 'preact';
import {useState, useEffect} from 'preact/hooks';
export default async () => {
render(, document.body);
};
function Extension() {
const [recommendations, setRecommendations] = useState(null);
useEffect(() => {
async function fetchRecommendations() {
const token = await shopify.sessionToken.get();
const res = await fetch('https://your-app.com/api/recommendations', {
headers: {Authorization: `Bearer ${token}`},
});
const data = await res.json();
setRecommendations(data.products);
}
fetchRecommendations();
}, []);
if (!recommendations || recommendations.length === 0) return null;
return (
{recommendations.map((product) => (
{product.title}
View product
))}
);
}
```
--------------------------------
### Link to the storefront
Source: https://shopify.dev/docs/api/customer-account-ui-extensions/latest/target-apis/order-apis/shop-api
Create a link back to the merchant's online store from your extension. This example reads `shopify.shop.storefrontUrl` and renders a "Continue Shopping" button that navigates to the storefront.
```APIDOC
## Link to the storefront
### Description
This example demonstrates how to create a link back to the merchant's online store using the `storefrontUrl` property of the `shopify.shop` object. It renders a "Continue Shopping" button that navigates the user to the storefront.
### Code Example (JSX)
```jsx
import '@shopify/ui-extensions/preact';
import {render} from 'preact';
export default async () => {
render(, document.body);
};
function Extension() {
const shop = shopify.shop;
return (
Continue Shopping
Browse more products from {shop.name}.
Visit {shop.name}
);
}
```
```
--------------------------------
### Stack: Align items to the start
Source: https://shopify.dev/docs/api/customer-account-ui-extensions/latest/web-components/layout-and-structure/stack
Use `alignment="start"` to align items to the beginning of the stack's cross axis. This is the default behavior.
```javascript
import {
Stack,
Text
} from "@shopify/polaris-react-ui";
function MyComponent() {
return (
First Item
Second Item
);
}
```
--------------------------------
### Query Products with shopify.query Helper
Source: https://shopify.dev/docs/api/customer-account-ui-extensions/latest/target-apis/platform-apis/storefront-api
Use the `shopify.query()` helper to run a Storefront GraphQL query with variables. This example fetches the first five products and renders their titles in a list. Requires the `api_access` capability.
```jsx
import '@shopify/ui-extensions/preact';
import {render} from 'preact';
import {useEffect, useState} from 'preact/hooks';
export default async () => {
render(, document.body);
};
function Extension() {
const [data, setData] = useState({});
useEffect(() => {
shopify
.query(
`query ($first: Int!) {
products(first: $first) {
nodes {
id
title
}
}
}`,
{
variables: {first: 5},
},
)
.then(({data, errors}) => {
setData(data);
})
.catch(console.error);
}, [setData]);
return (
{data?.products?.nodes.map((node) => {
return (
{node.title}
);
})}
);
}
```
--------------------------------
### Fetch Product Details using shopify.query()
Source: https://shopify.dev/docs/api/customer-account-ui-extensions/latest/target-apis/platform-apis/storefront-api
This snippet demonstrates how to query for a specific product's title and description using the `shopify.query()` helper. It includes basic loading and error handling.
```jsx
import '@shopify/ui-extensions/preact';
import {render} from 'preact';
import {useEffect, useState} from 'preact/hooks';
export default async () => {
render(, document.body);
};
function Extension() {
const [data, setData] = useState(null);
useEffect(() => {
shopify
.query(
`query ($id: ID!) {
product(id: $id) {
title
description
}
}`,
{
variables: {
id: 'gid://shopify/Product/1',
},
},
)
.then(({data}) => {
setData(data);
})
.catch(console.error);
}, []);
if (!data?.product) {
return ;
}
return (
{data.product.title}
{data.product.description}
);
}
```
--------------------------------
### MatchedSubstring Type
Source: https://shopify.dev/docs/api/customer-account-ui-extensions/latest/target-apis/platform-apis/extension-api
Represents a matched substring within text, including its length and starting offset.
```typescript
number
```
```typescript
number
```
--------------------------------
### Create a Two-Column Summary with Flexible Widths
Source: https://shopify.dev/docs/api/customer-account-ui-extensions/latest/web-components/layout-and-structure/grid
Use `gridTemplateColumns="1fr auto"` to create a two-column layout where the first column takes up available space and the second column fits its content. This is useful for pairing labels with values, like product names and prices.
```html
Plants for sale
Pothos
$25.00
```
--------------------------------
### Removable Chip Example
Source: https://shopify.dev/docs/api/customer-account-ui-extensions/latest/web-components/actions/clickable-chip
Displays a chip that can be dismissed by the user. Use the `removable` attribute to enable this functionality.
```html
Shipping insurance
```
--------------------------------
### Query products with the query helper
Source: https://shopify.dev/docs/api/customer-account-ui-extensions/latest/target-apis/platform-apis/storefront-api
Use the `shopify.query()` helper to run a Storefront GraphQL query with variables. This example fetches the first five products and renders their titles in a list.
```APIDOC
## shopify.query()
### Description
Queries the Storefront GraphQL API directly from your extension using a prefetched token. Use this to fetch product data, collection details, or other storefront information without routing requests through your app backend.
### Method
```javascript
query(query: string, options?: { variables?: Variables; version?: StorefrontApiVersion; }): Promise<{ data?: Data; errors?: GraphQLError[]; }>
```
### Parameters
#### Query Parameters
- **query** (string) - Required - The GraphQL query string.
- **options** (object) - Optional - An object containing query options.
- **variables** (object) - Optional - An object containing variables for the GraphQL query.
- **version** (StorefrontApiVersion) - Optional - The Storefront API version to target.
### Request Example
```jsx
import '@shopify/ui-extensions/preact';
import {render} from 'preact';
import {useEffect, useState} from 'preact/hooks';
export default async () => {
render(, document.body);
};
function Extension() {
const [data, setData] = useState({});
useEffect(() => {
shopify
.query(
`query ($first: Int!) {
products(first: $first) {
nodes {
id
title
}
}
}`,
{
variables: {first: 5},
},
)
.then(({data, errors}) => {
setData(data);
})
.catch(console.error);
}, [setData]);
return (
{data?.products?.nodes.map((node) => (
{node.title}
))}
);
}
```
### Response
#### Success Response
- **data** (object) - The data returned from the GraphQL query.
- **errors** (array) - An array of `GraphQLError` objects if the query failed.
### StorefrontApiVersion
The supported Storefront API versions.
```
'2022-04' | '2022-07' | '2022-10' | '2023-01' | '2023-04' | '2023-07' | '2024-01' | '2024-04' | '2024-07' | '2024-10' | '2025-01' | '2025-04' | 'unstable' | '2025-07' | '2025-10'
```
### GraphQLError
An error returned by the Storefront GraphQL API.
* **extensions** (object) - Additional error metadata including the request ID and error code.
* **requestId** (string)
* **code** (string)
* **message** (string) - A human-readable description of the error.
```
--------------------------------
### Submit Return Request in a Full-Page Extension
Source: https://shopify.dev/docs/api/customer-account-ui-extensions/latest/targets/full-page
This example shows a full-page extension for submitting return requests. It displays order items and allows users to select items for return, then submits the request. It utilizes `shopify.lines.value` to list order items.
```jsx
import '@shopify/ui-extensions/preact';
import {render} from 'preact';
import {useState} from 'preact/hooks';
export default async () => {
render(, document.body);
};
function Extension() {
const order = shopify.order.value;
const lines = shopify.lines.value;
const [submitted, setSubmitted] = useState(false);
if (!order) {
return null;
}
if (submitted) {
return (
navigation.navigate('shopify:customer-account/orders')}
>
Back to orders
Your return request has been submitted. We'll review it and get back to you.
);
}
return (
navigation.navigate('shopify:customer-account/orders')}
>
Back to orders
Select items to return from order {order.name}:
{lines.map((line) => (
{line.merchandise.title}
Qty: {line.quantity}
))}
setSubmitted(true)}>
Submit return request
);
}
```
--------------------------------
### Extension Editor Context
Source: https://shopify.dev/docs/api/customer-account-ui-extensions/latest/target-apis/platform-apis/extension-api
Get information about the editor environment where the extension is being rendered. Returns undefined if not in an editor.
```typescript
Editor
```
--------------------------------
### Link to Storefront using Shop API
Source: https://shopify.dev/docs/api/customer-account-ui-extensions/latest/target-apis/order-apis/shop-api
Create a link back to the merchant's online store from your extension. This example reads shop.storefrontUrl and renders a button that navigates to the storefront.
```jsx
import '@shopify/ui-extensions/preact';
import {render} from 'preact';
export default async () => {
render(, document.body);
};
function Extension() {
const shop = shopify.shop;
return (
Continue Shopping
Browse more products from {shop.name}.
Visit {shop.name}
);
}
```
--------------------------------
### Collect a password
Source: https://shopify.dev/docs/api/customer-account-ui-extensions/latest/web-components/forms/password-field
Add a password input that masks characters for privacy. This example shows a password field with a label and a defaultValue.
```html
```
--------------------------------
### Footer Target Example
Source: https://shopify.dev/docs/api/customer-account-ui-extensions/latest/targets
This target renders at the bottom of all customer account pages. Use it for global announcements or legal compliance.
```plaintext
customer-account.footer.render-after
```
--------------------------------
### Display Order Preparation Notice
Source: https://shopify.dev/docs/api/customer-account-ui-extensions/latest/targets/fulfillment-status
Show a banner informing customers that their items are being prepared for shipment. This example reads order data from `shopify.order` to include the order name for context. Always check that `shopify.order.value` is defined before rendering order-specific content.
```jsx
import '@shopify/ui-extensions/preact';
import {render} from 'preact';
export default async () => {
render(, document.body);
};
function Extension() {
const order = shopify.order.value;
if (!order) {
return null;
}
return (
Items from order {order.name} are being prepared. You'll receive tracking
details once they ship.
);
}
```
--------------------------------
### Display an order cost summary
Source: https://shopify.dev/docs/api/customer-account-ui-extensions/latest/target-apis/order-apis/cost-api
This example demonstrates how to render an order cost summary by accessing and displaying the subtotal, shipping, tax, and total amounts. It formats each amount with its corresponding currency code.
```APIDOC
## jsx
```jsx
import '@shopify/ui-extensions/preact';
import {render} from 'preact';
export default async () => {
render(, document.body);
};
function Extension() {
const subtotal = shopify.cost.subtotalAmount.value;
const shipping = shopify.cost.totalShippingAmount.value;
const tax = shopify.cost.totalTaxAmount.value;
const total = shopify.cost.totalAmount.value;
return (
Subtotal
{subtotal.amount}
{subtotal.currencyCode}
{shipping && (
Shipping
{shipping.amount}
{shipping.currencyCode}
)}
{tax && (
Tax
{tax.amount}
{tax.currencyCode}
)}
Total
{total.amount}
{total.currencyCode}
);
}
```
```
--------------------------------
### Inline Stack with Images
Source: https://shopify.dev/docs/api/customer-account-ui-extensions/latest/web-components/layout-and-structure/stack
Use an inline stack to arrange elements horizontally. This example displays multiple product images side-by-side.
```html
```
--------------------------------
### Show a disabled field
Source: https://shopify.dev/docs/api/customer-account-ui-extensions/latest/web-components/forms/url-field
Show a URL in a non-interactive state. This example uses disabled to gray out the field while keeping the value visible.
```html
```
--------------------------------
### Menu with Sections and Navigation
Source: https://shopify.dev/docs/api/customer-account-ui-extensions/latest/web-components/actions/menu
Organizes menu items into labeled sections using `s-section` components. This example demonstrates how to separate help resources from support options within a menu, with links opening in new tabs.
```html
Help
```
--------------------------------
### Limit Character Count
Source: https://shopify.dev/docs/api/customer-account-ui-extensions/latest/web-components/forms/text-area
Restrict input length and display the remaining character count. This example sets a maxLength of 200 characters.
```html
```
--------------------------------
### Calculate and Display Total Savings
Source: https://shopify.dev/docs/api/customer-account-ui-extensions/latest/target-apis/order-apis/discounts-api
Calculates and displays the total savings from all discount allocations. This example iterates over `shopify.discountAllocations` to sum the discounted amounts and shows a per-discount breakdown. It requires discount allocations to be present.
```jsx
import '@shopify/ui-extensions/preact';
import {render} from 'preact';
export default async () => {
render(, document.body);
};
function Extension() {
const allocations =
shopify.discountAllocations.value;
if (allocations.length === 0) {
return null;
}
const totalSavings = allocations.reduce(
(sum, allocation) =>
sum +
Number(allocation.discountedAmount.amount),
0,
);
const currencyCode =
allocations[0].discountedAmount.currencyCode;
return (
You saved {totalSavings.toFixed(2)}
{currencyCode}
{allocations.map((allocation, index) => (
-{allocation.discountedAmount.amount}
{
allocation.discountedAmount
.currencyCode
}
))}
);
}
```
--------------------------------
### Provide a text alternative
Source: https://shopify.dev/docs/api/customer-account-ui-extensions/latest/web-components/media-and-visuals/qr-code
Pair the QR code with a text link so all customers can access the content. This example adds a paragraph with a clickable link below the code for customers who can't scan.
```html
Scan to access your return label, or visit
shopify.com/returns/abc123
```
--------------------------------
### Grouped Switches for Preferences
Source: https://shopify.dev/docs/api/customer-account-ui-extensions/latest/web-components/forms/switch
Organize related preferences using a stack layout with multiple switches. This example shows notification preferences.
```html
```
--------------------------------
### Query Storefront API with fetch
Source: https://shopify.dev/docs/api/customer-account-ui-extensions/latest/target-apis/platform-apis/storefront-api
Use the global `fetch()` function to query the GraphQL Storefront API directly. This example fetches products using a POST request and renders the results. Requires the `api_access` capability.
```jsx
import '@shopify/ui-extensions/preact';
import {render} from 'preact';
import {useEffect, useState} from 'preact/hooks';
export default async () => {
render(, document.body);
};
function Extension() {
const [data, setData] = useState();
useEffect(() => {
const getProductsQuery = {
query: `query ($first: Int!) {
products(first: $first) {
nodes {
id
title
}
}
}`,
variables: {first: 5},
};
const apiVersion = 'unstable';
fetch(
`shopify://storefront/api/${apiVersion}/graphql.json`,
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(getProductsQuery),
},
)
.then((response) => response.json())
.then(({data, errors}) => setData(data))
.catch(console.error);
}, []);
return (
{data?.products?.nodes.map((node) => (
{node.title}
))}
);
}
```
--------------------------------
### Extension Target Identifier
Source: https://shopify.dev/docs/api/customer-account-ui-extensions/latest/target-apis/platform-apis/extension-api
Get the identifier specifying where the code is injected into Shopify's UI, as defined in the extension's configuration.
```typescript
Target
```
--------------------------------
### Prompting Login for Pre-Authenticated Buyers
Source: https://shopify.dev/docs/api/customer-account-ui-extensions/latest/target-apis/account-apis/authentication-state-api
Detect pre-authenticated buyers and encourage them to log in for a richer experience. This example checks `shopify.authenticationState` and displays a login prompt with a button that calls `shopify.requireLogin()`.
```jsx
import '@shopify/ui-extensions/preact';
import {render} from 'preact';
export default async () => {
render(, document.body);
};
function Extension() {
const authState =
shopify.authenticationState.value;
if (authState === 'pre_authenticated') {
return (
You are viewing a limited version of
this page. Sign in to see full order
details and manage your account.
shopify.requireLogin()}
>
Sign in
);
}
return (
You are fully authenticated.
);
}
```
--------------------------------
### Use in a grid layout
Source: https://shopify.dev/docs/api/customer-account-ui-extensions/latest/web-components/media-and-visuals/image
Arrange product photos in a row, each constrained to a square with rounded corners so they line up evenly. This example arranges three product photos in a row using a grid.
```html
```
--------------------------------
### Add border styling
Source: https://shopify.dev/docs/api/customer-account-ui-extensions/latest/web-components/media-and-visuals/image
Add visual emphasis with border styling. This example displays an image with border width, color, and rounded corners.
```html
```
--------------------------------
### Display a Basic Product Thumbnail
Source: https://shopify.dev/docs/api/customer-account-ui-extensions/latest/web-components/media-and-visuals/product-thumbnail
Use this snippet to show a standard product thumbnail with an image source and alt text for accessibility.
```html
```
--------------------------------
### Example shopify.extension.toml for Checkout UI Extension
Source: https://shopify.dev/docs/api/customer-account-ui-extensions/latest/configuration
This TOML file configures a checkout UI extension, including API version, extension details, capabilities, targeting information, and settings fields.
```toml
api_version = "2025-10"
[[extensions]]
name = "My UI extension"
description = "A UI extension"
handle = "my-ui-extension"
type = "ui_extension"
uid = "1aafc25d-8448-218e-9373-b3d91ac2a0af75f73e12"
[extensions.capabilities]
api_access = true
block_progress = true
network_access = true
[[extensions.targeting]]
module = "./src/CheckoutDynamicRender.js"
target = "purchase.checkout.block.render"
[[extensions.targeting.metafields]]
key = "my-key"
unique_id = "my-namespace"
[settings]
[[settings.fields]]
key = "banner_title"
type = "single_line_text_field"
name = "Banner title"
description = "Enter a title for the banner"
```
--------------------------------
### Render Subscriptions in Order Action Target
Source: https://shopify.dev/docs/api/customer-account-ui-extensions/latest/targets/order-actions
This example demonstrates how to fetch and display a customer's subscriptions within an order action target. It includes handling loading states and empty subscription lists. Ensure your API endpoint is correctly configured.
```jsx
import '@shopify/ui-extensions/preact';
import {render} from 'preact';
import {useState, useEffect} from 'preact/hooks';
export default async () => {
render(, document.body);
};
function Extension() {
const [subscriptions, setSubscriptions] = useState(null);
useEffect(() => {
async function fetchSubscriptions() {
const token = await shopify.sessionToken.get();
const res = await fetch('https://your-app.com/api/subscriptions', {
headers: {Authorization: `Bearer ${token}`},
});
const data = await res.json();
setSubscriptions(data.subscriptions);
}
fetchSubscriptions();
}, []);
if (!subscriptions) {
return (
);
}
if (subscriptions.length === 0) {
return null;
}
return (
{subscriptions.map((sub) => (
{sub.productName}
{sub.status}
Next billing: {sub.nextBillingDate}
))}
);
}
```
--------------------------------
### Collect a First Name
Source: https://shopify.dev/docs/api/customer-account-ui-extensions/latest/web-components/forms/text-field
Add a single-line text input with a pre-filled value. This example displays a text field with an optional label and a defaultValue.
```html
```
--------------------------------
### Set an aspect ratio
Source: https://shopify.dev/docs/api/customer-account-ui-extensions/latest/web-components/media-and-visuals/image
Compare different aspect ratios on the same image. This example stacks a 1:1 square crop above a 16:9 widescreen crop, both using `objectFit="cover"` to fill their containers.
```html
```