Skip to main content

<primer-main>

Optional container that provides structured slots for payment methods, checkout completion, and initialization errors. Handles state transitions (loading, success, error) automatically.

Quick reference


Examples

Default (all methods)

Renders all available payment methods automatically.

Custom payment methods

Custom success screen

Custom initialization error screen

For error details (e.g. to log or branch on the failure), listen for primer:state-change and read primerJsError from the event detail — see Error handling.

Both slots


Slots


Events

<primer-main> does not emit its own events. It subscribes to parent events internally to manage slot visibility. When bypassing <primer-main>, you handle these events yourself.

Relevant parent events

When you bypass <primer-main>

If you use a custom <div slot="main"> instead of <primer-main>, you must handle these events directly:

CSS properties


States

This component automatically manages visibility based on checkout state:

Usage guidelines

Do

  • Use for structured customization with automatic state handling
  • Include <primer-error-message-container> when customizing payments slot (for payment failures)
  • Provide custom success screen via checkout-complete slot
  • Provide a custom initialization-failure screen via checkout-error slot

Don’t

  • Don’t use if you need full control over state — use custom main slot on <primer-checkout> instead
  • Don’t confuse checkout-error (SDK initialization failures) with <primer-error-message-container> (payment failures) — see Error handling

Alternative: full customization

For complete control, bypass <primer-main>:

Content guidelines

Success screen text

Section headings


See also

primer-checkout

Parent component

Layout customization

Slot usage guide

Error handling

Error display patterns