Quick Fix
The core pattern is the same for all frameworks—load Primer inside a client-side lifecycle hook:Next.js
App Router (Recommended)
'use client' directive marks the component as client-side only.
Pages Router
Using next/dynamic (Alternative)
Disable SSR for the entire checkout component:For React 18 vs 19 patterns and handling payment events, see the React Integration Guide.
Nuxt.js
Nuxt 3
Use
import.meta.client in Nuxt 3. The older process.client still works but is a legacy pattern.Nuxt 2 Pattern
Nuxt 2 Pattern
SvelteKit
Show Loading State
Use theprimer:ready event to detect when the checkout is fully initialized:
- Next.js
- Nuxt 3
- SvelteKit
The
primer:ready event fires when the checkout has fully initialized with payment methods. The checkout element must be in the DOM to receive a client token and initialize.Troubleshooting
”customElements is not defined”
Primer code is running on the server. Fix: MoveloadPrimer() inside a client-side lifecycle hook (useEffect, onMounted, onMount).
“window is not defined”
Code is accessing browser globals during SSR. Fix: Add an environment check:Components Don’t Render
The checkout needs a valid client token to initialize. Fix: Ensure you’re passing a validclient-token attribute. Use the primer:ready event to detect when initialization is complete. See Show Loading State above.
TypeScript Errors
TypeScript doesn’t recognize<primer-checkout> as a valid element.
Fix: Add type declarations:
Why SSR Needs This
Technical explanation
Technical explanation
Server-side rendering frameworks execute code on the server to generate HTML before sending it to the browser. Primer Checkout depends on browser-only APIs:
- Web Components API –
customElements.define()only exists in browsers - DOM APIs – Component rendering requires the Document Object Model
- Window Object – Payment features depend on
windowand browser globals - Secure Iframes – Card inputs require a browser environment
Next Steps
React Integration
React 18/19 patterns and event handling
Styling
Customize the appearance
Events Guide
Handle payment success and failure
Troubleshooting
More solutions for common issues