Checkout Kit for Web
Agentic commerce is rolling out to Dev Dashboard. Sign up to be notified.
Agentic commerce is rolling out to Dev Dashboard. Sign up to be notified.
Integrate Shopify's checkout in your web application using Checkout Kit for Web. You can display checkout in a new tab, popup window, or embedded inline. The component preserves the merchant's branding, extensions, and payment settings.
Anchor to What you'll learnWhat you'll learn
- Integrate Checkout Kit into your web application.
- Present the checkout through a checkout URL or cart permalink.
- Configure checkout behavior with attributes
- Listen for checkout events
Anchor to RequirementsRequirements
- A valid Shopify checkout URL (from the Storefront API
cart.checkoutUrlfield or a cart permalink) - For authenticated checkouts:
client_idandclient_secretprovided by Shopify
Anchor to Step 1: Add Checkout KitStep 1: Add Checkout Kit
Install the npm package for production applications, or use the CDN for quick prototyping without build tools.
npm
Install the package and import the component:
CDN
Include the script directly in your HTML:
This CDN URL is for development and prototyping only.
This CDN URL is for development and prototyping only.
Install the package and import the component:
Anchor to Step 2: Add the checkout elementStep 2: Add the checkout element
Add a <shopify-checkout> element to your HTML. Use the checkout URL as the href for an anchor tag to provide a fallback if JavaScript is disabled:
HTML
Anchor to Step 3: Present checkoutStep 3: Present checkout
To present checkout to the buyer, your application must specify a checkout URL. To get this URL, you can:
- Use the Storefront API to build a cart and load its checkout URL.
- Get it from the Catalog MCP server or Catalog API product response (for agentic commerce).
- Create a cart permalink.
Set the src attribute to a checkout URL and call open():
JavaScript
Anchor to Step 4: Listen for eventsStep 4: Listen for events
The <shopify-checkout> component dispatches DOM events at key points in the checkout lifecycle. The following example listens for the checkout:complete event:
JavaScript
Anchor to ConfigurationConfiguration
Configure the component using attributes.
Required. The checkout URL from the Storefront API or a cart permalink.
HTML
Controls where the component renders.
auto(default): Opens in a new tab.popup: Opens in a popup window.inline: Renders inline. Requires authentication.
JavaScript
The JWT for inline embedding and configuration overrides. Required for inline mode. See Authentication below.
Anchor to MethodsMethods
The component exposes the following methods:
open(): Presents the component. Has no effect whentargetisinline.close(): Closes the component. Has no effect whentargetisinline.focus(): Brings the component to the foreground. Has no effect whentargetisinline.
Anchor to AuthenticationAuthentication
By default, the component opens in new tabs or popups without authentication. To embed inline or apply configuration overrides, you need to authenticate using a JWT.
Never expose your client_id or client_secret in client-side code. Token generation must occur server-side.
Never expose your client_id or client_secret in client-side code. Token generation must occur server-side.
Anchor to Generate a tokenGenerate a token
Create a secure server endpoint that generates tokens:
curl
Tokens have a 60-minute time-to-live (TTL) and can be cached for that duration.
Anchor to Use the tokenUse the token
Fetch the token from your backend and pass it to the component's auth attribute: