Skip to main content

Shop SDK

The Shop SDK is a JavaScript library for integrating Shop functionality into any storefront. Load a single script from Shopify's CDN, initialize the SDK with your configuration, and create feature instances programmatically.

Load the SDK loader script and call initialize with your client ID. The apiKey is the client ID from your Dev Dashboard app.

The script registers window.ShopSDK when it loads. Call sdk.create() with a feature name to create a feature instance. The method returns a Promise that resolves once the feature's code has loaded.

The SDK creates the underlying HTML element. You're responsible for inserting instance.element into the DOM.


  • apiKey: Your client ID from the Dev Dashboard.
  • appearance: Styling overrides. See Appearance.
  • features: Eagerly preload feature scripts. For example, { 'lead-capture': true } starts loading the lead capture code immediately.
  • locale: BCP-47 locale tag (for example, 'en', 'fr', 'ro-RO'). Defaults to 'en'.
  • onError / onReady / onRecognized: SDK-level event handlers. See Event handlers.
  • scope: Space-separated list of OAuth scopes to request.

Control the look of SDK components with CSS custom properties on appearance.variables. Component-level variables set when calling sdk.create() take precedence over SDK-level ones.

VariableDescription
--buttons-radiusBorder radius for buttons.
--font-paragraph--line-heightLine height for paragraph text.
--font-paragraph--sizeFont size for paragraph text.
--x-spacing-baseBase spacing unit.

SDK-level event handlers fire for all feature instances. Pass them as top-level properties on the initialize config.

HandlerPayloadDescription
onError{ message, cause, feature }Fires when an error occurs in any feature instance.
onReady{ elementTagName, detail }Fires when a feature instance finishes loading.
onRecognized{ recognized }Fires when a Shop user is detected (or not) in the current session.

Call sdk.update() to merge new configuration into a live SDK instance, or sdk.destroy() to tear down all feature instances. The locale option is fixed at initialization and can't be updated.



Was this page helpful?