Skip to main content

Beyond Prisma ORM

As a Prisma ORM user, you're already experiencing the power of type-safe database queries and intuitive data modeling. When scaling production applications, however, new challenges emerge. As an app matures it’s a given that you’ll begin to experience connection pooling complexities, find ways to effectively cache common queries, or develop sophisticated, event-driven systems to handle real-time or time-sensitive features.

Instead of spending your valuable time overcoming these challenges, let’s explore how Prisma can help by extending the capabilities of the ORM as your application grows.

Boost application performance with Prisma Accelerate

As your application scales, you'll likely need tools to handle increased traffic efficiently. This often involves implementing connection pooling to manage database connections and caching strategies to reduce database load and improve response times. Prisma Accelerate addresses these needs in a single solution, eliminating the need to set up and manage separate infrastructure.

Prisma Accelerate is particularly useful for applications deployed to serverless and edge environments (also know as Function-as-a-Service) because these deployments lend themselves towards many orders of magnitude more connections being created than a traditional, long-lived application. For these apps, Prisma Accelerate has the added benefit of protecting your database from day one and keeping your app online regardless of traffic you experience.

Try out the Accelerate speed test to see what’s possible.

Improve query performance with connection pooling

Place your connection pooler in one of 15+ global regions, minimizing latency for database operations. Enable high-performance distributed workloads across serverless and edge environments.

Reduce query latency and database load with caching

Cache query results across 300+ global points of presence. Accelerate extends your Prisma Client, offering intuitive, granular control over caching patterns such as ttl and swr on a per-query basis.

Handle scaling traffic with managed infrastructure

Scale to millions of queries per day without infrastructure changes. Efficiently manage database connections and serve more users with fewer resources.

Get started with Accelerate today

Accelerate integrates seamlessly with your Prisma ORM project through the @prisma/extension-accelerate client extension. Get started quickly with our setup guide and instantly access full edge environment support, connection pooling, and global caching.

import { PrismaClient } from '@prisma/client'
import { withAccelerate } from '@prisma/extension-accelerate'

// 1. Extend your Prisma Client with the Accelerate extension
const prisma = new PrismaClient().$extends(withAccelerate())

// 2. (Optionally) add cache to your Prisma queries
const users = await prisma.user.findMany({
cacheStrategy: {
ttl: 30, // Consider data fresh for 30 seconds
swr: 60 // Serve stale data for up to 60 seconds while fetching fresh data
}
})

To see more examples, visit our examples repo or try them out yourself with npx try-prisma.

Build real-time, event-driven applications with Prisma Pulse

HTTP requests resulting in reads and writes to your database is straightforward with Prisma ORM. But what if you wanted to trigger specific code based on events or only run a given function based on changes to your database?

With Pulse, you can reliably stream database changes directly to your application! No need to constantly poll the database for changes or set up complex infrastructure to achieve this.

Pulse extends your Prisma Client, giving you an API that allows you to react to database changes as they happen with the same, great developer experience of Prisma ORM.

import { PrismaClient } from '@prisma/client'
import { withPulse } from '@prisma/extension-pulse'

// Extend your Prisma Client with the Pulse extension
const prisma = new PrismaClient().$extends(
withPulse({ apiKey: process.env.PULSE_API_KEY })
)

// You're now ready to develop real-time features with Pulse!
const stream = await prisma.user.stream()

for await (const event of stream) {
console.log('Received database event:', event)

}
info

View the event object and Pulse API: Pulse API Reference

Simplify event-driven workflows

Remove the need for complicated scheduling and queues and let events arrive directly from your database.

// Stream new users on the `User` model in real-time
const stream = await prisma.user.stream({
create: {}, // This stream will include any User.create event.
name: 'user-create-events' // Name is optional, but allows you to stop and restart the stream without losing any events.
});

for await (let event of stream) {
const { email } = event.created;

// Send welcome email to user after sign up
await sendWelcomeEmail({ email });
}

Build real-time experiences

When someone sends a chat message through your app, it’s critical that it’s delivered quickly. Power any real-time functionality with Pulse as the database-event engine.

// Stream unread messages on the `Message` model in real-time
const stream = await prisma.message.stream({
create: { read: false }, // Filter for unread messages
});

for await (let event of stream) {
const { senderId, message, chatId } = event.created;

// Update the chat UI and send a notification
await sendMessageInChat({ senderId, message, chatId });
}

Keep services in sync

Synchronize data to external services when your data changes without cluttering your code with extra API calls.

// Stream new orders on the `Order` model in real-time
const stream = await prisma.order.stream({
create: {}, // This stream will include any User.create event.
name: 'user-create-events' // Name is optional, but allows you to stop and restart the stream without losing any events.
});

for await (let event of stream) {
const { orderId, orderItems } = event.created;

// Update the inventory
await updateExternalInventoryFromOrder({ orderId, orderItems });
}

To see more examples, visit our examples repo or try them out yourself with npx try-prisma.

.

Grow with Prisma

Both Accelerate and Pulse take features built into Prisma ORM and build upon them by adding additional capabilities like globally-optimized caching and real-time data synchronization. Get started for free the and explore how Accelerate and Pulse can help you build scalable, high-performance applications!

Improving developer experience doesn’t stop at Accelerate and Pulse. Prisma is building and expanding our products to improve every aspect of Data DX and we’d love to hear what you think. Join our community and learn more about our products below.

Both Accelerate and Pulse build on Prisma ORM through Prisma Client Extensions. This opens up features that we couldn’t include in the ORM like globally-optimized caching and real-time data synchronization. Create a free account and explore how Accelerate and Pulse can help you build scalable, high-performance applications!

Improving developer experience doesn’t stop at Accelerate and Pulse. Prisma is building and expanding our products to improve every aspect of Data DX and we’d love to hear what you think. Join our community and learn more about our products below