<primer-provider>
Makes a checkout’s payment session available to Primer components rendered outside<primer-checkout>. Use it when your layout places payment UI elsewhere on the page — a fixed footer, a separate column, or a dialog that renders into document.body.
Primer components only work inside <primer-checkout>. A component placed anywhere else renders nothing, and the browser console shows a warning naming <primer-provider>. Wrap it in a <primer-provider> that references the checkout by its id.
Quick reference
Examples
Basic usage
Inside a React portal
Most component libraries render a dialog intodocument.body, outside the checkout. Wrap the dialog content in a provider:
Showing a success message
The provider renders nothing once the payment succeeds. Show your confirmation outside it:Attributes
States
The provider renders its content only while the payment session is active, the same as thepayments slot of <primer-main>.
This prevents a second payment from being started after the first one succeeds. Everything inside the provider is hidden in these states, including your own markup.
Usage guidelines
Do
- Give
<primer-checkout>anidand pass the same value tocheckout-id - Render
<primer-checkout>before the provider. If the checkout is not in the page when the provider connects, the provider logs an error and does not retry - Place success and error messages outside the provider, and show them using
primer:payment-successorprimer:state-change
Don’t
- Don’t place
<primer-checkout>inside another element’s shadow DOM — the provider looks it up withdocument.getElementById, which does not search shadow roots - Don’t use a provider inside
<primer-checkout>— components there already have access to the session
Troubleshooting
See also
primer-checkout
The component that owns the payment session
primer-main
Slots and state handling inside the checkout
Layout customization
Slot usage guide