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.
- Example repo with step-by-step tutorial
- Strategy and payment flow docs to help your agent implement the pattern
How it works:
- User clicks "Buy" — a UUID token is generated and saved to
localStoragebefore redirecting to Stripe Checkout - The token is passed to Stripe via session metadata
- On payment, a webhook creates a
purchaserecord in Instant linked to that token - Permissions gate the protected content — only queries that include a valid purchase token (via
ruleParams) can see the full-resolution URLs - 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.
- Example repo with step-by-step tutorial
- Strategy and subscription flow docs to help your agent implement the pattern
How it works:
- User signs in via magic code auth
- Checkout creates or reuses a Stripe customer linked to the Instant user
- Stripe webhooks sync
subscriptionStatusto the$usersrecord whenever the subscription changes (created, updated, canceled, deleted) - Permissions gate premium content — the
contentfield is simply omitted from query results for non-subscribers - 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.
- Example repo with step-by-step tutorial
- Strategy and credit flow docs to help your agent implement the pattern
How it works:
- User signs in via magic code auth
- Checkout creates a Stripe customer and processes a one-time payment for a credit pack
- The webhook adds credits to the user's
creditsfield, with idempotency protection via Stripe session metadata to prevent double-crediting on retries - A server-side API route verifies the user has enough credits, then atomically deducts a credit and creates the result in a single transaction
- Instant's real-time subscriptions keep the credit balance and history updated in the UI instantly