惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Google DeepMind News
Google DeepMind News
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
酷 壳 – CoolShell
酷 壳 – CoolShell
WordPress大学
WordPress大学
小众软件
小众软件
博客园 - 司徒正美
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Jina AI
Jina AI
Hugging Face - Blog
Hugging Face - Blog
博客园 - Franky
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
量子位
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
雷峰网
雷峰网
云风的 BLOG
云风的 BLOG
M
MIT News - Artificial intelligence
F
Fortinet All Blogs
T
Tailwind CSS Blog
Martin Fowler
Martin Fowler
I
InfoQ
The GitHub Blog
The GitHub Blog
有赞技术团队
有赞技术团队
The Cloudflare Blog
罗磊的独立博客

Supabase Blog

AI Agents Know About Supabase. They Don't Always Use It Right. Custom OIDC Providers for Supabase Auth 100,000 GitHub stars Supabase docs over SSH Navigating Regional Network Blocks Supabase Joins the Stripe Projects Developer Preview Log Drains: Now available on Pro Supabase Storage: major performance, security, and reliability updates Supabase incident on February 12, 2026 Hydra joins Supabase X / Twitter OAuth 2.0 is now available for Supabase Auth BKND joins Supabase Supabase is now an official Claude connector Supabase PrivateLink is now available Introducing: Postgres Best Practices When to use Read Replicas vs. bigger compute Introducing TRAE SOLO integration with Supabase Supabase Security Retro: 2025 Sync Stripe Data to Your Supabase Database in One Click Building ChatGPT Apps with Supabase Edge Functions and mcp-use Own Your Observability: Supabase Metrics API Introducing iceberg-js: A JavaScript Client for Apache Iceberg Introducing Supabase for Platforms Adding Async Streaming to Postgres Foreign Data Wrappers Build "Sign in with Your App" using Supabase Auth Introducing Seven New Email Templates for Supabase Auth The new Supabase power for Kiro Introducing Supabase ETL Introducing Analytics Buckets Introducing Vector Buckets
Stripe-To-Postgres Sync Engine as standalone Library
Kevin Grüneberg · 2025-07-15 · via Supabase Blog

Stripe-To-Postgres Sync Engine as standalone Library

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.

Why sync Stripe data to 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:

  • Lower latency: Avoid round-trips to the Stripe API.
  • Better joins: Query subscriptions, invoices, and charges together.
  • Custom logic: Build fraud checks, billing dashboards, and dunning workflows directly from your own database.

You can now install and run the Stripe sync engine directly inside your backend:


_10

npm install @supabase/stripe-sync-engine


And use it like this:


_10

import { StripeSync } from '@supabase/stripe-sync-engine'

_10

_10

const sync = new StripeSync({

_10

databaseUrl: 'postgres://user:pass@host:port/db',

_10

stripeSecretKey: 'sk_test_...',

_10

stripeWebhookSecret: 'whsec_...',

_10

})

_10

_10

// Example: process a Stripe webhook

_10

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


_10

import { runMigrations } from '@supabase/stripe-sync-engine'

_10

;(async () => {

_10

await runMigrations({

_10

databaseUrl: 'postgresql://postgres:..@db.<ref>.supabase.co:5432/postgres',

_10

schema: 'stripe',

_10

logger: console,

_10

})

_10

})()


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:


_31

import 'jsr:@supabase/functions-js/edge-runtime.d.ts'

_31

_31

import { StripeSync } from 'npm:@supabase/stripe-sync-engine@0.39.0'

_31

_31

// Load secrets from environment variables

_31

const databaseUrl = Deno.env.get('DATABASE_URL')!

_31

const stripeWebhookSecret = Deno.env.get('STRIPE_WEBHOOK_SECRET')!

_31

const stripeSecretKey = Deno.env.get('STRIPE_SECRET_KEY')!

_31

_31

// Initialize StripeSync

_31

const stripeSync = new StripeSync({

_31

databaseUrl,

_31

stripeWebhookSecret,

_31

stripeSecretKey,

_31

backfillRelatedEntities: false,

_31

autoExpandLists: true,

_31

})

_31

_31

Deno.serve(async (req) => {

_31

// Extract raw body as Uint8Array (buffer)

_31

const rawBody = new Uint8Array(await req.arrayBuffer())

_31

_31

const stripeSignature = req.headers.get('stripe-signature')

_31

_31

await stripeSync.processWebhook(rawBody, stripeSignature)

_31

_31

return new Response(null, {

_31

status: 202,

_31

headers: { 'Content-Type': 'application/json' },

_31

})

_31

})


  1. Deploy your Edge Function initially using supabase functions deploy
  2. Set up a Stripe webhook with the newly deployed Supabase Edge Function url
  3. Create a new .env file in the supabase directory


_10

# Use Dedicated pooler if available

_10

DATABASE_URL="postgresql://postgres:..@db.<ref>.supabase.co:6532/postgres"

_10

STRIPE_WEBHOOK_SECRET="whsec_"

_10

STRIPE_SECRET_KEY="sk_test_..."


  1. Load the secrets using sh supabase secrets set --env-file ./supabase/.env

As 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.