Migrating
Migrate your POS UI Extension to use the latest unified ui-extension package.
Anchor to overviewOverview
POS UI Extensions are moving to the newer package, shared with Checkout UI Extensions and Admin UI Extensions. This will allow your extensions to use the same package regardless of the surface they extend, and for a single extension to implement multiple targets across different surfaces of Shopify more easily.
and
are deprecated. They are now maintained as part of
and
. This guide explains how to migrate from the old packages to the new ones.
Migration requires a minimum CLI version of 3.64.0.
Anchor to setupSetup
- Before starting, make sure you have the most up to date version of the Shopify CLI.
- Navigate to your
package.json
in the directory of your UI Extension. You'll need to removeor
(whichever you're using).
- If you use React, replace your version of
react
and(if you use typescript) with version 18 and up.
does not support any version prior to React 18.
- Next you'll need to add the new dependencies,
or
. Consult our changelog to see supported versions. If you are using the
package, you will also need to install
.
Setup
examples
Setup
yarn
# 1. Update Shopify CLI yarn global add @shopify/cli@latest # 2. Remove the old packages yarn remove @shopify/retail-ui-extensions* # 3. Upgrade React yarn upgrade react@^18.2.0 yarn upgrade @types/react@^18.2.0 # 4. Install the new packages yarn add @shopify/ui-extensions@2024.4 yarn add @shopify/ui-extensions-react@2024.4
npm
# 1. Update Shopify CLI npm i -g @shopify/cli@latest # 2. Remove the old packages npm uninstall @shopify/retail-ui-extensions* # 3. Upgrade React npm update react@^18.2.0 npm update @types/react@^18.2.0 # 4. Install the new packages npm install @shopify/ui-extensions@2024.4 npm install @shopify/ui-extensions-react@2024.4
Anchor to code-changesCode changes
- Replace imports from
with
. Replace imports from
with
.
- Replace calls to
extend
withextension
and replace calls torender
with. Move each call to
extension
andto individual files, and export them with an
export default
statement.
Code changes
examples
Code changes
React
// Before import React from 'react' import { Tile, useApi, render } from '@shopify/retail-ui-extensions-react' const SmartGridTile = () => { const api = useApi<'pos.home.tile.render'>() return ( <Tile title="My app" subtitle="SmartGrid Extension" onPress={() => { api.smartGrid.presentModal() }} enabled /> ) } render('pos.home.tile.render', () => <SmartGridTile />) // After import React from 'react' import { Tile, useApi, reactExtension } from '@shopify/ui-extensions-react/point-of-sale' const SmartGridTile = () => { const api = useApi<'pos.home.tile.render'>() return ( <Tile title="My app" subtitle="SmartGrid Extension" onPress={() => { api.action.presentModal() }} enabled /> ) } export default reactExtension('pos.home.tile.render', () => <SmartGridTile />)
TS
// Before import {extend, Tile} from '@shopify/retail-ui-extensions'; extend('pos.home.tile.render', (root, api) => { const tile = root.createComponent(Tile, { title: 'My app', subtitle: 'SmartGrid Extension', onPress: () => api.smartGrid.presentModal(), enabled: true, }); root.append(tile); root.mount(); }); // After import {extension, Tile} from '@shopify/ui-extensions/point-of-sale'; export default extension('pos.home.tile.render', (root, api) => { const tile = root.createComponent(Tile, { title: 'My app', subtitle: 'SmartGrid Extension', onPress: () => api.action.presentModal(), enabled: true, }); root.append(tile); });
Anchor to configurationConfiguration
Migrate your shopify.extension.toml
file to reflect the new syntax.
- Specify which
you are using at the top of the file (above
[[extensions]]
). This will let POS know which version of theui-extensions
package you're using.
needs to be declared in a
yyyy-mm
format. If you are using version
2024.4
for example, you must declare your as 2024-04. The patch is irrelevant to
.
- Declare each extension target and file path in
shopify.extension.toml
Configuration
shopify.extension.toml
examples
Configuration
shopify.extension.toml
api_version = "2024-04" [[extensions]] type = "ui_extension" name = "my-tutorial-extension" handle = "my-tutorial-extension" description = "Tutorial extension!" [[extensions.targeting]] module = "./src/Tile.tsx" target = "pos.home.tile.render" [[extensions.targeting]] module = "./src/Modal.tsx" target = "pos.home.modal.render"
Anchor to validationValidation
Validate your migration by running yarn dev
or npm run dev
Anchor to finalizeFinalize the migration
- Deploy your app by running
npm run deploy
. - When prompted to migrate your extension from
to
, select "Yes, confirm migration from pos_ui_extension".
- Your extension should now deploy as the new ui_extension type.