hydrogen-shop-pay
Skill218 starsChanged 4 days agoMITView on GitHub
Guide for adding or reviewing Shop Pay buttons in Hydrogen storefronts. Use when working with ShopPayButton, renderShopPayButton, createShopPayButton, product buy buttons, cart checkout acceleration, variant IDs, quantities, or source attribution attributes.
1 other project uses a version of this, 1 of them edited.
Adopted by
Most recently taken up by
- Shopify/hydrogenedited, first seen Oct 13, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 1
- Shopify/hydrogen★ 2.2k99% same
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository23 other files it gives its agents.
- AGENTS.mdAGENTS.md
- hydrogen-analyticsSkill
- hydrogen-cart-drawerSkill
- hydrogen-cart-metafieldsSkill
- hydrogen-cart-uiSkill
- hydrogen-collection-browserSkill
- hydrogen-customer-accountSkill
- hydrogen-imageSkill
- hydrogen-local-httpsSkill
- hydrogen-marketsSkill
- hydrogen-moneySkill
- hydrogen-oxygenSkill
- hydrogen-predictive-searchSkill
- hydrogen-request-handlersSkill
- hydrogen-robots-txtSkill
- hydrogen-routingSkill
- hydrogen-setupSkill
- hydrogen-smoke-testSkill
- hydrogen-storefront-clientSkill
- hydrogen-variant-formSkill
- migrate-to-hydrogen-2026-10Skill
- remix-storeSkill
- testing-practicesSkill
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 0 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 31
Use quantity objects when quantity is known: { id: selectedVariant.id, quantity }.
- Very specific: line 37
Keep Shop Pay near the primary purchase action, and keep its disabled state aligned with canAddToCart(...).
- Very specific: line 83
If the button renders but checkout fails, verify variant ID format and that handleShopifyRoutes handles the request first.
≈ “Common” is an estimate: at least 1 in 5 of the 372,429 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Shop Pay
Hydrogen renders the Shop Pay button locally as a <hydrogen-shop-pay-button>
with a declarative shadow root. The shadow root protects the branded styles and
contains an anchor pointing at the storefront's own /checkout or
/cart/<id>:<qty> permalink paths, which handleShopifyRoutes redirects to the
store's real checkout. No external script loads and the server-rendered button
works before any JavaScript runs.
Framework References
Before writing UI, check whether this skill has a reference file for the app's framework in references/. If one exists, read it and use that framework binding. If there is no matching reference, use references/core.md and wire the framework-neutral helpers into the app's existing component and routing conventions.
Rules
- For product buy buttons, render Shop Pay only when there is a resolved ProductVariant ID.
- Pass ProductVariant GIDs or bare numeric ProductVariant IDs. Product IDs are invalid.
- Use quantity objects when quantity is known:
{ id: selectedVariant.id, quantity }. - For cart checkout buttons, omit
variants; checkout mode uses the current cart. - Disable Shop Pay whenever the add-to-cart button is disabled or a product/cart mutation is pending.
- Omit
channelunless the integration needs explicitheadlessorhydrogencheckout attribution and knows which sales channel issued its Storefront API token. - Omit
checkoutUrlwhen the app routes same-origin checkout paths throughhandleShopifyRoutes. Otherwise pass the cart checkout URL. - Pass
nonceonly when the storefront's Content Security Policy requires nonces for inline<style>elements. The nonce authorizes the shadow-root stylesheet, not thestyleattribute used bywidthandborderRadius; strict policies must allow inline style attributes for those custom dimensions. - Keep Shop Pay near the primary purchase action, and keep its disabled state aligned with
canAddToCart(...). - Size with
widthandborderRadius; arbitraryclassNameandstyleoverrides are intentionally not supported because the branded button is isolated inside its shadow root. PassaccessibilityLabelwhen the storefront language is not English, and never translate theShop Paybrand name.
Product Page Pattern
{selectedVariant ? (
<ShopPayButton
variants={[{ id: selectedVariant.id, quantity }]}
disabled={!addable || pending}
width="100%"
borderRadius="9999px"
/>
) : null}addable should come from canAddToCart(product, options), not from checking selectedVariant alone.
Cart Pattern
For a full-cart checkout shortcut, render Shop Pay without variants and hide or disable it when the cart is empty or a cart mutation is pending.
{cart.lines.nodes.length > 0 ? (
<ShopPayButton
disabled={cartPending}
width="100%"
borderRadius="4px"
/>
) : null}Verify
Done when:
- Product buy buttons render Shop Pay only when a resolved ProductVariant ID exists.
- Shop Pay's disabled state matches the add-to-cart button (disabled when add-to-cart is disabled or a product/cart mutation is pending).
- Product buttons pass ProductVariant GIDs or bare numeric variant IDs (never Product IDs), with a quantity object when quantity is known.
- Cart checkout buttons omit
variantsand are hidden or disabled when the cart is empty or a mutation is pending. checkoutUrlis omitted only whenhandleShopifyRouteshandles the same-origin checkout paths.
Gotchas
- The button's same-origin URLs only check out if the app routes requests through
handleShopifyRoutes, which redirects/checkoutand/cart/<id>:<qty>permalinks to the store's checkout. - Disabled buttons render without an
href(witharia-disabled="true"), so nothing navigates while a mutation is pending. - If the button renders but checkout fails, verify variant ID format and that
handleShopifyRouteshandles the request first.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

