apps/www/_blog/2025-07-15-stripe-engine-as-sync-library.mdx
We're excited to announce that stripe-sync-engine is now available as a standalone npm package: @supabase/stripe-sync-engine!
Previously distributed only as a Docker image (supabase/stripe-sync-engine), you can now plug this into any backend project—whether you're using Node.js, running Express on a server, or even deploying on Supabase Edge Functions.
Stripe-Sync-Engine is a webhook listener that transforms Stripe webhooks into structured Postgres inserts/updates. It listens to Stripe webhook events (like invoice.payment_failed, customer.subscription.updated, etc), normalizes and stores them in a relational format in Postgres.
While Supabase offers a convenient foreign data wrapper (FDW) for Stripe, sometimes you want your Stripe data locally available in your Postgres database for:
You can now install and run the Stripe sync engine directly inside your backend:
npm install @supabase/stripe-sync-engine
And use it like this:
import { StripeSync } from '@supabase/stripe-sync-engine'
const sync = new StripeSync({
databaseUrl: 'postgres://user:pass@host:port/db',
stripeSecretKey: 'sk_test_...',
stripeWebhookSecret: 'whsec_...',
})
// Example: process a Stripe webhook
await sync.processWebhook(payload, signature)
For a full list of configuration options, refer to our stripe-sync-engine README.
To use the Stripe-Sync-Engine in an Edge Function, you first have to ensure that the schema and tables exist. While you can technically do this inside the Edge Function, it is recommended to run the schema migrations outside of that. You can do a one-off migration via
import { runMigrations } from '@supabase/stripe-sync-engine'
;(async () => {
await runMigrations({
databaseUrl: 'postgresql://postgres:..@db.<ref>.supabase.co:5432/postgres',
schema: 'stripe',
logger: console,
})
})()
or include the migration files in your regular migration workflow.
Once the schema and tables are in place, you can start syncing your Stripe data using an Edge Function:
import 'jsr:@supabase/functions-js/edge-runtime.d.ts'
import { StripeSync } from 'npm:@supabase/[email protected]'
// Load secrets from environment variables
const databaseUrl = Deno.env.get('DATABASE_URL')!
const stripeWebhookSecret = Deno.env.get('STRIPE_WEBHOOK_SECRET')!
const stripeSecretKey = Deno.env.get('STRIPE_SECRET_KEY')!
// Initialize StripeSync
const stripeSync = new StripeSync({
databaseUrl,
stripeWebhookSecret,
stripeSecretKey,
backfillRelatedEntities: false,
autoExpandLists: true,
})
Deno.serve(async (req) => {
// Extract raw body as Uint8Array (buffer)
const rawBody = new Uint8Array(await req.arrayBuffer())
const stripeSignature = req.headers.get('stripe-signature')
await stripeSync.processWebhook(rawBody, stripeSignature)
return new Response(null, {
status: 202,
headers: { 'Content-Type': 'application/json' },
})
})
supabase functions deploysupabase directory# Use Dedicated pooler if available
DATABASE_URL="postgresql://postgres:..@db.<ref>.supabase.co:6532/postgres"
STRIPE_WEBHOOK_SECRET="whsec_"
STRIPE_SECRET_KEY="sk_test_..."
sh supabase secrets set --env-file ./supabase/.envAs webhooks come in, the data is automatically persisted in the stripe schema. For a full guide, please refer to our repository docs.
If you're building with Stripe and Supabase, stripe-sync-engine gives you a reliable, scalable way to bring your billing data closer to your database and application. Whether you want better analytics, faster dunning workflows, or simpler integrations—this package is built to make that seamless.