Integrate Commerce Engine Checkout into Astro sites using the root checkout helpers. No dedicated binding needed — works with ClientRouter and framework islands.
Astro does not need a dedicated checkout binding. Use the root @commercengine/checkout helpers (initCheckout, getCheckout, subscribeToCheckout) directly in layout scripts or client modules.
Feature flags, login methods, drawer direction, and payment provider are managed in Checkout Studio (Config API), not as SDK init options. Use theme only for per-session overrides.
If you use React, Vue, Svelte, or Solid islands inside Astro, you can use the corresponding framework binding’s hook/composable/store inside the island. The checkout instance is shared — initCheckout only needs to be called once in the layout.
src/components/CartButton.tsx
// React island exampleimport { useCheckout } from "@commercengine/checkout/react";export function CartButton() { const { openCart, cartCount, isReady } = useCheckout(); return ( <button onClick={openCart} disabled={!isReady}> Cart ({cartCount}) </button> );}
src/pages/index.astro
---import { CartButton } from "../components/CartButton";---<CartButton client:load />
If your Astro app also uses the @commercengine/storefront SDK, you must use authMode: "provided" with two-way token sync. Create a client module that owns both the storefront session and checkout init:
<script> import { initHostedCheckout } from "@/lib/storefront-client"; function bootstrap() { void initHostedCheckout(); } bootstrap(); document.addEventListener("astro:page-load", bootstrap);</script>
If your Astro app uses the first-party @commercengine/storefront/astro wrapper instead of the base SPA SDK, see the Astro SDK Integration page for the equivalent pattern using storefront.bootstrap() and clientStorefront().
Preserving the iframe across ClientRouter navigations
Astro’s ClientRouter replaces document.body on each navigation, which remounts any body-mounted checkout iframe. If remounting is acceptable, no extra work is needed.If you need to keep the iframe alive across page transitions, install a custom swap that only replaces your page content region instead of the full body: