Skip to main content

What is Pulse

Overview

Prisma Pulse facilitates the implementation of event-driven workflows and architectures by providing managed infrastructure that captures databases events and distributes them to your applications.

It lets you subscribe to any changes happening in your database using Prisma Client to power real-time use cases in your applications, such as:

  • chat and messaging
  • sending onboarding emails
  • data syncing (e.g. into a search index)
  • social collaboration
  • notifying users
  • updating inventories
  • managing payments
  • live games, quizzes and polls
  • ... and many other functionalities that require real-time updates

Prisma Pulse integrates with Prisma ORM and lets you subscribe to database changes easily and in a type-safe way using Prisma Client.

Here's the brief overview of how Pulse works:

1. Subscribe to database changes with Prisma Client

In this example, we subscribe to all changes that are happening on the User table in the database:

// subscribe to all changes on the `User` table
const subscription = await prisma.user.subscribe()

// wait for new events to arrive
for await (let event of subscription) {

// log the details about an event to the terminal
console.log(`Something happened in the database: `)
console.log(event)
}

2. A database event happens

A change is made to the table we've previously subscribed to. In this case, a new row is added to the User table.

This change can happen from anywhere, the same app that uses Prisma Client to subscribe to changes, a different application or microserivce, a database GUI or any other SQL client (like psql).

3. The database event is propagated to all subscribers

Prisma Pulse propagates the event to all subscribers. In this case, the application from step 1. receives the event and logs its value to the terminal:

Something happened in the database:
{
"action": "create",
"created": {
"id": 1,
"email": "test@prisma.io",
"name": "test"
}
}

Why Prisma Pulse?

Building real-time functionality based on changes that occur in your database can be very complicated. Common approaches like polling, implementing application-level updates or using additional infrastructure (like Apache Kafka or RabbitMQ) either don't scale, are very costly or come with substantial development and maintenance overhead.

Instead, Prisma Pulse is based on the idea of unidirectional data flow which is implemented via Change Data Capture (CDC). CDC gets rid of the deficiencies of the previously mentioned approaches and solves the problem of reacting to database events in a robust and elegant manner.

Here is an overview of the main features Prisma Pulse provides:

  • Reacting to database changes with type-safe model subscriptions
  • Unidirectional data flow via Change Data Capture
  • Great DX integrated with usage of Prisma ORM (easy setup, development and maintenance)
  • Works with your existing database
  • Insights dashboard lets you view and understand all database events captured by Pulse
  • Enable, disable and manage Pulse via the Platform CLI

How does Prisma Pulse work?

Prisma Pulse uses CDC to efficiently observe and capture database changes as they occur. By monitoring the database's transaction log (e.g. the Write-Ahead-Log in PostgreSQL), Prisma Pulse identifies database change events like inserts, updates, and deletes without impacting the database's performance.

The captured events are processed, evaluated, and distributed to all Prisma Client instances that subscribed to them:

What is Pulse

What can you build with Prisma Pulse?

Prisma Pulse can power real-time functionality like chat, notifications, data broadcast, data synchronization, and more. It's ideal for ensuring data consistency in distributed systems, enhancing real-time user experiences.

Prisma Pulse use-cases

Example projects

Here are a few example projects using Prisma Pulse:

ProjectDescription
pulse-starterGeneral Pulse starter project.
pulse-resend-demoOptimize your onboarding with Pulse by triggering welcome emails via Resend for new user sign-ups.