Customer account UI extensions let app developers build custom functionality that merchants can install at defined points on the **Order index**, **Order status**, and **Profile** pages in customer accounts. > Shopify Plus: >Some static extensions on the Profile page only render for B2B customers. B2B on Shopify is only available on the [Shopify Plus](https://www.shopify.com/plus) plan. [See B2B Profile targets](/api/customer-account-ui-extensions/unstable/extension-targets-overview#profile-b2b)
Use Shopify CLI to [generate a new extension](/apps/tools/cli/commands#generate-extension) in the directory of your app.
npm init @shopify/app@latest
cd your-app
npm run shopify app generate extension
yarn create @shopify/app
cd your-app
yarn shopify app generate extension
pnpm create @shopify/app
cd your-app
pnpm shopify app generate extension
Extension targets provide locations for customer account UI extensions to appear. Extension UIs are rendered using [remote UI](https://github.com/Shopify/remote-ui), a fast and secure environment for custom [(non-DOM)](#security) UIs.
import {
reactExtension,
Banner,
useTranslate,
} from '@shopify/ui-extensions-react/customer-account';
reactExtension('customer-account.order-index.block.render', () => (
<App />
));
function App() {
const translate = useTranslate();
return <Banner>{translate('welcomeMessage')}</Banner>;
}
import {
extension,
Banner,
} from '@shopify/ui-extensions/customer-account';
extension(
'customer-account.order-status.block.render',
(root, api) => {
const banner = root.createComponent(
Banner,
{},
api.i18n.translate('welcomeMessage'),
);
root.appendChild(banner);
},
);
When you create a customer account UI extension, the shopify.extension.toml file is automatically generated in your customer account UI extension directory. It contains the extension's configuration, which includes the extension name, extension targets, metafields, capabilities and settings definition.
api_version = "unstable"
[[extensions]]
name = "My customer account ui extension"
handle = "customer-account-ui"
type = "ui_extension"
[[extensions.targeting]]
target = "customer-account.order-status.block.render"
module = "./Extension.jsx"
APIs enable customer account UI extensions to get information about the customer or related objects and to perform actions. For example, you can use APIs to retrieve previous orders of the customer so that you can offer related products as upsells. Extensions use JavaScript to read and write data and call external services, and natively render UIs built using Shopify's checkout and customer account components.
import {
reactExtension,
Banner,
useTranslate,
} from '@shopify/ui-extensions-react/customer-account';
reactExtension(
'customer-account.order-status.block.render',
() => <App />,
);
function App() {
const translate = useTranslate();
return <Banner>{translate('welcomeMessage')}</Banner>;
}
import {
extension,
Banner,
} from '@shopify/ui-extensions/customer-account';
extension(
'customer-account.order-status.block.render',
(root, api) => {
renderApp(root, api);
},
);
function renderApp(root, api) {
// In case of a re-render, remove previous children.
for (const child of root.children) {
root.removeChild(child);
}
const banner = root.createComponent(
Banner,
{},
api.i18n.translate('welcomeMessage'),
);
root.appendChild(banner);
}
Customer account UI extensions declare their interface using supported UI components. Shopify renders the UI natively so it's performant, accessible, and works in all of customer account supported browsers. Components are designed to be flexible, enabling you to layer and mix them to create highly-customized app extensions that feel seamless within the customer account experience. All components that will inherit a merchant's brand settings and the CSS cannot be altered or overridden. To build customer account UI extensions, you can use checkout components, and customer account components.
import {
reactExtension,
BlockStack,
InlineStack,
Button,
Image,
Text,
} from '@shopify/ui-extensions-react/customer-account';
reactExtension(
'customer-account.order-status.block.render',
() => <App />,
);
function App() {
return (
<InlineStack>
<Image source="/url/for/image" />
<BlockStack>
<Text size="large">Heading</Text>
<Text size="small">Description</Text>
</BlockStack>
<Button
onPress={() => {
console.log('button was pressed');
}}
>
Button
</Button>
</InlineStack>
);
}
import {
extension,
BlockStack,
Button,
Image,
InlineStack,
Text,
} from '@shopify/ui-extensions/customer-account';
extension(
'customer-account.order-status.block.render',
(root) => {
const inlineStack = root.createComponent(
InlineStack,
{},
[
root.createComponent(Image, {
source: '/url/for/image',
}),
root.createComponent(BlockStack, {}, [
root.createComponent(
Text,
{size: 'large'},
'Heading',
),
root.createComponent(
Text,
{size: 'small'},
'Description',
),
]),
root.createComponent(
Button,
{
onPress: () => {
console.log('button was pressed');
},
},
'Button',
),
],
);
void root.appendChild(inlineStack);
},
);
Use the `shopify:customer-account` protocol when you want to construct a URL with a root of customer accounts.
<Link to="shopify:customer-account/orders" />
fetch(
'shopify:customer-account/api/unstable/graphql.json',
{
method: 'POST',
body: JSON.stringify(simpleOrderQuery),
},
);
Relative URLs are relative to your extension and are useful when you want to link to a route in your extension.
<Link to={`/subscriptions/${subscription.id}`} />
Triggers a navigation to an extension using the `extension:` protocol. The handle is the handle of the extension that will be navigated to in the same application. Build a [full-page extension](/apps/customer-accounts/full-page-extension) to create a new page in customer accounts and handle the navigation.
<Link
to={`extension:${extension.handle}/${path}`}
>
To full-page extension
</Link>;
<Link
to={`extension:${extension.handle}/customer-account.order.page.render/${orderId}/${path}`}
>
To full-page extension (order-specific)
</Link>;
Custom protocols make it easier to navigate to common locations, and construct URLs.
Customer account UI extensions are a safe and secure way to customize the appearance and functionality of the customer account pages without compromising the security of customer data. - They run in an isolated sandbox, separate from the customer account page and other UI extensions. - They don't have access to sensitive payment information or the customer account page itself (HTML or other assets). - They are limited to specific UI components and APIs that are exposed by the platform. - They have limited access to [global web APIs](https://github.com/Shopify/ui-extensions/blob/unstable/documentation/runtime-environment.md). - Apps that wish to access [protected customer data](/docs/apps/store/data-protection/protected-customer-data), must submit an application and are subject to strict security guidelines and review proccesses by Shopify.
Find an end-to-end guide to testing your extensions in [Testing customer account UI extensions](https://shopify.dev/docs/apps/customer-accounts/best-practices/testing-ui-extensions).
Learn how to build customer account UI extensions using APIs and UI components.