Skip to main content

Extension API

The Extension API lets you read metadata about your extension at runtime, including its handle and URL. Use this API to build dynamic URLs that point to your extension, read editor context when it's available, or log extension details for debugging.

  • Build extension URLs: Use the extension's url property to construct links that point back to your extension or share its location with your backend.
  • Conditionally render by editor type: Check editor.type to display different content depending on where the extension is rendered.
  • Log extension details for debugging: Include the extension handle and url in error reports or diagnostic output to identify which extension instance is running.
Support
Targets (24)

The shopify global object provides extension metadata for customer account extensions. Access the following properties on shopify to read your extension's handle, URL, and editor context at runtime.

Anchor to extension
extension
required

Metadata about the extension, including its target, version, and editor context. Use this to conditionally render content based on where the extension is running.


  • Use the handle for identification: Reference shopify.extension.handle when logging or communicating with your backend so you can identify which extension is active.
  • Check editor type defensively: The editor property may be undefined in some contexts. Always use optional chaining (editor?.type) when accessing it.
  • Don't hardcode extension URLs: Use shopify.extension.url instead of constructing URLs manually. The URL may vary between development and production environments.

Was this page helpful?