Instant features

Stripe Payments

The quickest way to add Stripe to your Instant app is to tell your LLM to do it. Just say "add Stripe payments" and follow along step by step.

For more guidance we've put together three reference examples with tutorials you can follow along. Each example also has addiitonal docs you can copy and paste for your agent.

#Stripe Examples

All three patterns share the same core idea: Stripe handles payment, Instant handles data and access control. When a payment completes, Stripe's webhook writes to Instant via the Admin SDK, and any queries on the client get updated instantly.

#One-off purchase

This example is for a wallpaper store where users buy a pack and get immediate access to high-resolution downloads. It's a one-off payment and no user accounts required to minimize friction.

How it works:

  1. User clicks "Buy" — a UUID token is generated and saved to localStorage before redirecting to Stripe Checkout
  2. The token is passed to Stripe via session metadata
  3. On payment, a webhook creates a purchase record in Instant linked to that token
  4. Permissions gate the protected content — only queries that include a valid purchase token (via ruleParams) can see the full-resolution URLs
  5. Bonus: Uses magic code auth to let users sign in and retrieve past purchases

#Subscription

This example is for a blog where free users see teasers and subscribers get full articles. It uses recurring billing with Stripe and auth-based access control.

How it works:

  1. User signs in via magic code auth
  2. Checkout creates or reuses a Stripe customer linked to the Instant user
  3. Stripe webhooks sync subscriptionStatus to the $users record whenever the subscription changes (created, updated, canceled, deleted)
  4. Permissions gate premium content — the content field is simply omitted from query results for non-subscribers
  5. Stripe's Billing Portal handles cancellation and payment method updates

#Credits

This example is for a haiku generator where each generation costs one credit. Users buy packs of 10 credits for $2. It's a pay-per-use model with real-time balance updates.

How it works:

  1. User signs in via magic code auth
  2. Checkout creates a Stripe customer and processes a one-time payment for a credit pack
  3. The webhook adds credits to the user's credits field, with idempotency protection via Stripe session metadata to prevent double-crediting on retries
  4. A server-side API route verifies the user has enough credits, then atomically deducts a credit and creates the result in a single transaction
  5. Instant's real-time subscriptions keep the credit balance and history updated in the UI instantly
Previous
Storage