Skip to content

VueStripeCheckoutProvider

Initializes a Custom Checkout session (ui_mode: 'custom') via stripe.initCheckout() and provides it to descendants. Pair it with the useCheckoutSession composable to drive a fully custom checkout UI built from Stripe Elements.

Custom Checkout vs. the other checkout options

  • VueStripeCheckoutProvider (this) — full UI control with your own Elements, backed by a Checkout Session (ui_mode: 'custom').
  • VueStripeCheckout — redirect / hosted Checkout.
  • VueStripePricingTable — embed a Dashboard-configured pricing table.

Requirements

  • Must be used inside VueStripeProvider.
  • Needs a Checkout Session created on your server with ui_mode: 'custom'; pass its client_secret to the provider.

Usage

vue
<template>
  <VueStripeProvider :publishable-key="publishableKey">
    <VueStripeCheckoutProvider :client-secret="clientSecret">
      <CheckoutForm />
    </VueStripeCheckoutProvider>
  </VueStripeProvider>
</template>

<script setup>
import { VueStripeProvider, VueStripeCheckoutProvider } from '@vue-stripe/vue-stripe'
import CheckoutForm from './CheckoutForm.vue'

const publishableKey = import.meta.env.VITE_STRIPE_PUBLISHABLE_KEY
// From your backend: stripe.checkout.sessions.create({ ui_mode: 'custom', ... })
const clientSecret = 'cs_test_xxx_secret_xxx'
</script>

CheckoutForm (a descendant) then calls useCheckoutSession() to read the reactive session and mutate/confirm it.

Props

PropTypeRequiredDescription
clientSecretstringNo*Client secret of a ui_mode: 'custom' Checkout Session. Wrapped automatically into a fetchClientSecret for Stripe
fetchClientSecret() => Promise<string>No*Async function returning the client secret. Use for refreshable sessions; takes precedence over clientSecret
elementsOptionsobjectNoAppearance / fonts options forwarded to the Checkout Elements (initCheckout({ elementsOptions }))

* Provide either clientSecret or fetchClientSecret. If neither is set, the error slot renders.

Events

EventPayloadDescription
@readyStripeCheckoutEmitted once the Checkout session is initialized. Payload is the StripeCheckout instance
@errorstringEmitted if initCheckout() fails. Payload is the error message

Slots

SlotPropsRendered when
default{ checkout, session }Session is ready
loadingWhile initCheckout() is in flight
error{ error }Initialization failed
vue
<VueStripeCheckoutProvider :client-secret="clientSecret">
  <template #loading><div>Preparing checkout…</div></template>
  <template #error="{ error }"><div class="error">{{ error }}</div></template>

  <CheckoutForm />
</VueStripeCheckoutProvider>

Provides

KeyTypeDescription
checkoutRef<StripeCheckout | null>The Checkout instance
sessionRef<StripeCheckoutSession | null>Reactive session snapshot (updates on every Stripe change)
loadingRef<boolean>Whether the session is initializing
errorRef<string | null>Initialization error, if any

Access these via useCheckoutSession().

See Also

Released under the MIT License.