use Extensionhook
Returns the metadata about the extension.
Anchor to useExtensionuse Extension()
- apiVersion
The API version that was set in the extension config file.
- capabilitiesStatefulRemoteSubscribable<[]>
The allowed capabilities of the extension, defined in your shopify.extension.toml file.
- renderedStatefulRemoteSubscribable<boolean>
Whether your extension is currently rendered to the screen.
Shopify might render your extension before it's visible in the UI, typically to pre-render extensions that will appear on a later step of the checkout.
Your extension might also continue to run after the buyer has navigated away from where it was rendered. The extension continues running so that your extension is immediately available to render if the buyer navigates back.
- scriptUrlstring
The URL to the script that started the extension target.
- targetTarget
The identifier that specifies where in Shopify’s UI your code is being injected. This will be one of the targets you have included in your extension’s configuration file.
- editor
Information about the editor where the extension is being rendered.
The value is undefined if the extension is not rendering in an editor.
- versionstring
The published version of the running extension target.
For unpublished extensions, the value is
undefined
.
Extension
UseExtensionGeneratedType
Returns the metadata about the extension.
Extension
export function useExtension(): Extension {
return useApi().extension as Extension;
}
Extension
Meta information about an extension target.
- apiVersion
The API version that was set in the extension config file.
ApiVersion
- capabilities
The allowed capabilities of the extension, defined in your [shopify.extension.toml](/docs/api/checkout-ui-extensions/configuration) file. * [`api_access`](/docs/api/checkout-ui-extensions/configuration#api-access): the extension can access the Storefront API. * [`network_access`](/docs/api/checkout-ui-extensions/configuration#network-access): the extension can make external network calls. * [`block_progress`](/docs/api/checkout-ui-extensions/configuration#block-progress): the extension can block a buyer's progress and the merchant has allowed this blocking behavior.
StatefulRemoteSubscribable<Capability[]>
- editor
Information about the editor where the extension is being rendered. The value is undefined if the extension is not rendering in an editor.
Editor
- rendered
Whether your extension is currently rendered to the screen. Shopify might render your extension before it's visible in the UI, typically to pre-render extensions that will appear on a later step of the checkout. Your extension might also continue to run after the buyer has navigated away from where it was rendered. The extension continues running so that your extension is immediately available to render if the buyer navigates back.
StatefulRemoteSubscribable<boolean>
- scriptUrl
The URL to the script that started the extension target.
string
- target
The identifier that specifies where in Shopify’s UI your code is being injected. This will be one of the targets you have included in your extension’s configuration file.
Target
- version
The published version of the running extension target. For unpublished extensions, the value is `undefined`.
string
export interface Extension<Target extends ExtensionTarget = ExtensionTarget> {
/**
* The API version that was set in the extension config file.
*
* @example '2023-04', '2023-07'
*/
apiVersion: ApiVersion;
/**
* The allowed capabilities of the extension, defined
* in your [shopify.extension.toml](/docs/api/checkout-ui-extensions/configuration) file.
*
* * [`api_access`](/docs/api/checkout-ui-extensions/configuration#api-access): the extension can access the Storefront API.
*
* * [`network_access`](/docs/api/checkout-ui-extensions/configuration#network-access): the extension can make external network calls.
*
* * [`block_progress`](/docs/api/checkout-ui-extensions/configuration#block-progress): the extension can block a buyer's progress and the merchant has allowed this blocking behavior.
*/
capabilities: StatefulRemoteSubscribable<Capability[]>;
/**
* Information about the editor where the extension is being rendered.
*
* The value is undefined if the extension is not rendering in an editor.
*/
editor?: Editor;
/**
* Whether your extension is currently rendered to the screen.
*
* Shopify might render your extension before it's visible in the UI,
* typically to pre-render extensions that will appear on a later step of the
* checkout.
*
* Your extension might also continue to run after the buyer has navigated away
* from where it was rendered. The extension continues running so that
* your extension is immediately available to render if the buyer navigates back.
*/
rendered: StatefulRemoteSubscribable<boolean>;
/**
* The URL to the script that started the extension target.
*/
scriptUrl: string;
/**
* The identifier that specifies where in Shopify’s UI your code is being
* injected. This will be one of the targets you have included in your
* extension’s configuration file.
*
* @example 'purchase.checkout.block.render'
* @see /docs/api/checkout-ui-extensions/2023-07/extension-targets-overview
* @see /docs/apps/app-extensions/configuration#targets
*/
target: Target;
/**
* The published version of the running extension target.
*
* For unpublished extensions, the value is `undefined`.
*
* @example 3.0.10
*/
version?: string;
}
ApiVersion
Union of supported API versions
'2023-04' | '2023-07' | 'unstable'
Capability
The capabilities an extension has access to. * [`api_access`](/docs/api/checkout-ui-extensions/configuration#api-access): the extension can access the Storefront API. * [`network_access`](/docs/api/checkout-ui-extensions/configuration#network-access): the extension can make external network calls. * [`block_progress`](/docs/api/checkout-ui-extensions/configuration#block-progress): the extension can block a buyer's progress and the merchant has allowed this blocking behavior.
'api_access' | 'network_access' | 'block_progress'
Editor
- type
Indicates whether the extension is rendering in the checkout editor.
"checkout"
export interface Editor {
/**
* Indicates whether the extension is rendering in the checkout editor.
*/
type: 'checkout';
}