DEV Community

Alex Spinov
Alex Spinov

Posted on

Prisma Pulse Has a Free API You Should Know About

Prisma Pulse is a real-time database change stream API that lets you react to database changes instantly. No polling, no webhooks, no complex CDC setup — just subscribe to changes and get notified.

Why Prisma Pulse Changes Everything

A developer building a collaborative document editor was polling their database every 500ms to check for changes. Their server was handling 120 requests/second just for polling. With Prisma Pulse, they replaced all of that with a single subscription.

Key Features:

  • Real-time Change Streams — Subscribe to INSERT, UPDATE, DELETE events
  • Type-safe — Full TypeScript support with Prisma's type system
  • Filtered Subscriptions — Only receive changes matching your criteria
  • Resumable Streams — Pick up where you left off after disconnection
  • Works with Any Database — PostgreSQL support with more coming

Quick Start

npm install @prisma/extension-pulse
Enter fullscreen mode Exit fullscreen mode
import { PrismaClient } from "@prisma/client"
import { withPulse } from "@prisma/extension-pulse"

const prisma = new PrismaClient().$extends(withPulse({ apiKey: process.env.PULSE_API_KEY }))

// Subscribe to all new users
const subscription = await prisma.user.subscribe({
  create: {}
})

for await (const event of subscription) {
  console.log("New user created:", event.created)
}
Enter fullscreen mode Exit fullscreen mode

Filtered Subscriptions

// Only get notified about high-value orders
const subscription = await prisma.order.subscribe({
  create: {
    after: {
      amount: { gt: 1000 }
    }
  }
})

for await (const event of subscription) {
  await sendSlackAlert(`High-value order: \$${event.created.amount}`)
}
Enter fullscreen mode Exit fullscreen mode

Real-World Use Cases

  1. Live dashboards — Update metrics in real-time
  2. Notifications — Trigger alerts on specific database changes
  3. Cache invalidation — Automatically clear cache when data changes
  4. Audit logs — Track every change to critical data
  5. Sync systems — Keep multiple services in sync

Getting Started

Visit Prisma Pulse docs to set up your first real-time subscription.


Need real-time data from the web? Check out my Apify actors for production-ready web scraping tools, or email spinov001@gmail.com for custom data extraction solutions.

Top comments (0)