agentleFS
remix-runremix-run/remix-store/.agents/skills/hydrogen-shop-pay/SKILL.md

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

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
  1. Very specific:

    Use quantity objects when quantity is known: { id: selectedVariant.id, quantity }.

    line 31
  2. Very specific:

    Keep Shop Pay near the primary purchase action, and keep its disabled state aligned with canAddToCart(...).

    line 37
  3. Very specific:

    If the button renders but checkout fails, verify variant ID format and that handleShopifyRoutes handles the request first.

    line 83

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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 channel unless the integration needs explicit headless or hydrogen checkout attribution and knows which sales channel issued its Storefront API token.
  • Omit checkoutUrl when the app routes same-origin checkout paths through handleShopifyRoutes. Otherwise pass the cart checkout URL.
  • Pass nonce only when the storefront's Content Security Policy requires nonces for inline <style> elements. The nonce authorizes the shadow-root stylesheet, not the style attribute used by width and borderRadius; 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 width and borderRadius; arbitrary className and style overrides are intentionally not supported because the branded button is isolated inside its shadow root. Pass accessibilityLabel when the storefront language is not English, and never translate the Shop Pay brand 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 variants and are hidden or disabled when the cart is empty or a mutation is pending.
  • checkoutUrl is omitted only when handleShopifyRoutes handles the same-origin checkout paths.

Gotchas

  • The button's same-origin URLs only check out if the app routes requests through handleShopifyRoutes, which redirects /checkout and /cart/<id>:<qty> permalinks to the store's checkout.
  • Disabled buttons render without an href (with aria-disabled="true"), so nothing navigates while a mutation is pending.
  • If the button renders but checkout fails, verify variant ID format and that handleShopifyRoutes handles the request first.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.