:::callout{intent="warning"}
Accelerate retirement

Prisma Accelerate, including hosted Accelerate connections for Prisma Postgres, will be retired on December 1, 2026. Choose the path that matches your setup:

- [Migrate a PostgreSQL database to Prisma Postgres](/guides/migrating-off-accelerate-prisma-postgres-import-from-existing-database-postgresql)
- [Keep your existing database and remove Accelerate](/guides/migrating-off-accelerate-accelerate-keep-your-database)
- [Connect to Prisma Postgres without Accelerate](/guides/migrating-off-accelerate-postgres-database-switch-from-accelerate)
:::

## [Prerequisites](#prerequisites)

To get started with Accelerate, you will need the following:

- A [Prisma Data Platform account](https://console.prisma.io/?utm_source=docs\&utm_medium=content\&utm_content=accelerate)
- A project that uses [Prisma Client](/guides/prisma-client-v7-setup-and-configuration-introduction) `4.16.1` or higher. If your project is using interactive transactions, you need to use `5.1.1` or higher. (We always recommend using the latest version of Prisma.)
- A hosted PostgreSQL, MySQL/MariaDB, PlanetScale, CockroachDB, or MongoDB database

## [1. Enable Accelerate](#1-enable-accelerate)

Navigate to your Prisma Data Platform project, choose an environment, and enable Accelerate by providing your database connection string and selecting the region nearest your database.

:::callout{intent="note"}
If you require IP allowlisting or firewall configurations with trusted IP addresses, enable Static IP. Learn more on [how to enable static IP for Accelerate in the Platform Console](/guides/features-static-ip).
:::

## [2. Add Accelerate to your application](#2-add-accelerate-to-your-application)

### [2.1. Update your database connection string](#21-update-your-database-connection-string)

Once enabled, you'll be prompted to generate a connection string that you'll use to authenticate requests.

Replace your direct database URL with your new Accelerate connection string.

```title=".env"
# New Accelerate connection string with generated API_KEY

DATABASE_URL="prisma://accelerate.prisma-data.net/?api_key=__API_KEY__"

# Previous (direct) database connection string

# DATABASE_URL="postgresql://user:password@host:port/db_name?schema=public"
```

Prisma Client reads the `prisma://` URL from `DATABASE_URL` at runtime, while Prisma CLI commands use the connection string defined in `prisma.config.ts`.

Prisma Migrate and Introspection do not work with a `prisma://` connection string. In order to continue using these features add a new variable to the `.env` file named `DIRECT_DATABASE_URL` whose value is the direct database connection string:

```title=".env"
DATABASE_URL="prisma://accelerate.prisma-data.net/?api_key=__API_KEY__"

DIRECT_DATABASE_URL="postgresql://user:password@host:port/db_name?schema=public"
```

Then point `prisma.config.ts` to the direct connection string:

```title="prisma.config.ts"
import "dotenv/config";

import { defineConfig, env } from "prisma/config";

export default defineConfig({

  schema: "prisma/schema.prisma",

  datasource: {

    url: env("DIRECT_DATABASE_URL"),

  },

});
```

Migrations and introspections will use the `directUrl` connection string rather than the one defined in `url` when this configuration is provided.

> `directUrl` is useful for you to carry out migrations and introspections. However, you don't need `directUrl` to use Accelerate in your application.

:::callout{intent="note"}
If you are using Prisma with PostgreSQL, there is no need for `directUrl`, as Prisma Migrate and Introspection work with the `prisma+postgres://` connection string.
:::

### [2.2. Install the Accelerate Prisma Client extension](#22-install-the-accelerate-prisma-client-extension)

:::callout{intent="note"}
💡 Accelerate requires [Prisma Client](/guides/prisma-client-v7-setup-and-configuration-introduction) version `4.16.1` or higher and [`@prisma/extension-accelerate`](https://www.npmjs.com/package/@prisma/extension-accelerate) version `1.0.0` or higher.

💡 Accelerate extension [`@prisma/extension-accelerate`](https://www.npmjs.com/package/@prisma/extension-accelerate) version `2.0.0` and above requires Node.js version `18` or higher.
:::

Install the latest version of Prisma Client and Accelerate Prisma Client extension

:::code-group
```title="bun"
bun add @prisma/client@latest @prisma/extension-accelerate
```

```bash title="pnpm"
pnpm add @prisma/client@latest @prisma/extension-accelerate
```

```bash title="yarn"
yarn add @prisma/client@latest @prisma/extension-accelerate
```

```bash title="npm"
npm install @prisma/client@latest @prisma/extension-accelerate
```
:::

### [2.3. Generate Prisma Client for Accelerate](#23-generate-prisma-client-for-accelerate)

If you're using Prisma version `5.2.0` or greater, Prisma Client will automatically determine how it should connect to the database depending on the protocol in the database connection string. If the connection string in the `DATABASE_URL` starts with `prisma://`, Prisma Client will try to connect to your database using Prisma Accelerate.

When using Prisma Accelerate in long-running application servers, such as a server deployed on AWS EC2, you can generate the Prisma Client by executing the following command:

::::tabs
:::tab{title="bun"}
```
bunx prisma generate
```
:::

:::tab{title="pnpm"}
```bash
pnpm prisma generate
```
:::

:::tab{title="yarn"}
```bash
yarn prisma generate
```
:::

:::tab{title="npm"}
```bash
npx prisma generate
```

When using Prisma Accelerate in a Serverless or an Edge application, we recommend you to run the following command to generate Prisma Client:
:::
::::

When using Prisma Accelerate in a Serverless or an Edge application, we recommend you to run the following command to generate Prisma Client:

::::tabs
:::tab{title="bun"}
```
bunx prisma generate --no-engine
```
:::

:::tab{title="pnpm"}
```bash
pnpm prisma generate --no-engine
```
:::

:::tab{title="yarn"}
```bash
yarn prisma generate --no-engine
```
:::

:::tab{title="npm"}
```bash
npx prisma generate --no-engine
```

The `--no-engine` flag prevents a Query Engine file from being included in the generated Prisma Client, this ensures the bundle size of your application remains small.

> \[!WARNING]
> If your Prisma version is below `5.2.0`, generate Prisma Client with the `--accelerate` option:
>
> #### bun

> ````
> ```bash
> bunx prisma generate --accelerate
> ```
> ````
>
> #### pnpm

> ````
> ```bash
> pnpm prisma generate --accelerate
> ```
> ````
>
> #### yarn

> ````
> ```bash
> yarn prisma generate --accelerate
> ```
> ````
>
> #### npm

> ````
> ```bash
> npx prisma generate --accelerate
> ```
> ````
>
> If your Prisma version is below `5.0.0`, generate Prisma Client with the `--data-proxy` option:
>
> #### bun

> ````
> ```bash
> bunx prisma generate --data-proxy
> ```
> ````
>
> #### pnpm

> ````
> ```bash
> pnpm prisma generate --data-proxy
> ```
> ````
>
> #### yarn

> ````
> ```bash
> yarn prisma generate --data-proxy
> ```
> ````
>
> #### npm

> ````
> ```bash
> npx prisma generate --data-proxy
> ```
> ````
:::
::::

The `--no-engine` flag prevents a Query Engine file from being included in the generated Prisma Client, this ensures the bundle size of your application remains small.

:::::callout{intent="warning"}
If your Prisma version is below `5.2.0`, generate Prisma Client with the `--accelerate` option:

::::tabs
:::tab{title="bun"}
```
bunx prisma generate --accelerate
```
:::

:::tab{title="pnpm"}
:::

:::tab{title="yarn"}
:::

:::tab{title="npm"}
:::
::::

If your Prisma version is below `5.0.0`, generate Prisma Client with the `--data-proxy` option:

::::tabs
:::tab{title="bun"}
```
bunx prisma generate --data-proxy
```
:::

:::tab{title="pnpm"}
:::

:::tab{title="yarn"}
:::

:::tab{title="npm"}
:::
::::
:::::

### [2.4. Extend your Prisma Client instance with the Accelerate extension](#24-extend-your-prisma-client-instance-with-the-accelerate-extension)

Add the following to extend your existing Prisma Client instance with the Accelerate extension:

```
import { PrismaClient } from "@prisma/client";

import { withAccelerate } from "@prisma/extension-accelerate";

const prisma = new PrismaClient({

  accelerateUrl: process.env.DATABASE_URL,

}).$extends(withAccelerate());
```

If you are going to deploy to an edge runtime (like Cloudflare Workers, Vercel Edge Functions, Deno Deploy, or Supabase Edge Functions), use our edge client instead:

```
import { PrismaClient } from "@prisma/client/edge";

import { withAccelerate } from "@prisma/extension-accelerate";

const prisma = new PrismaClient({

  accelerateUrl: process.env.DATABASE_URL,

}).$extends(withAccelerate());
```

If VS Code does not recognize the `$extends` method, refer to [this section](/guides/more-faq#vs-code-does-not-recognize-the-extends-method) on how to resolve the issue.

#### [Using the Accelerate extension with other extensions](#using-the-accelerate-extension-with-other-extensions)

Since [extensions are applied one after another](/guides/prisma-client-v7-client-extensions#conflicts-in-combined-extensions), make sure you apply them in the correct order. Extensions cannot share behavior and the last extension applied takes precedence.

If you are using [Query Insights](/guides/manage-query-insights) in your application, make sure you apply it _before_ the Accelerate extension. For example:

```
const prisma = new PrismaClient({

  accelerateUrl: process.env.DATABASE_URL,

})

  .$extends(withOptimize())

  .$extends(withAccelerate());
```

### [2.5. Use Accelerate in your database queries](#25-use-accelerate-in-your-database-queries)

The `withAccelerate` extension primarily does two things:

- Gives you access to the `cacheStrategy` field within each applicable model method that allows you to define a cache strategy per-query.
- Routes all of your queries through a connection pooler.

#### [No cache strategy to only use connection pool](#no-cache-strategy-to-only-use-connection-pool)

To use Accelerate's connection pooling without applying a cache strategy, run your query the same way you would without Accelerate.

By enabling Accelerate and supplying the Accelerate connection string, your queries now use the connection pooler by default.

:::callout{intent="note"}
As of Prisma version `5.2.0` you can use Prisma Studio with the Accelerate connection string.
:::

#### [Invalidate the cache and keep your cached query results up-to-date](#invalidate-the-cache-and-keep-your-cached-query-results-up-to-date)

If your application requires real-time or near-real-time data, cache invalidation ensures that users see the most current data, even when using a large `ttl` (Time-To-Live) or `swr` (Stale-While-Revalidate) [cache strategy](/guides/features-caching). By invalidating your cache, you can bypass extended caching periods to show live data whenever it's needed.

For example, if a dashboard displays customer information and a customer's contact details change, cache invalidation allows you to refresh only that data instantly, ensuring support staff always see the latest information without waiting for the cache to expire.

To invalidate a cached query result, you can add tags and then use the `$accelerate.invalidate` API.

:::callout{intent="note"}
On-demand cache invalidation is available with our paid plans. For more details, please see our [pricing](https://www.prisma.io/pricing#accelerate).
:::

To invalidate the query below:

```
await prisma.user.findMany({

  where: {

    email: {

      contains: "alice@prisma.io",

    },

  },

  cacheStrategy: {

    swr: 60,

    ttl: 60,

    tags: ["emails_with_alice"], 

  },

});
```

You need to provide the cache tag in the `$accelerate.invalidate` API:

```
try {

  await prisma.$accelerate.invalidate({

    tags: ["emails_with_alice"], 

  }); 

} catch (e) {

  if (e instanceof Prisma.PrismaClientKnownRequestError) {

    // The .code property can be accessed in a type-safe manner

    if (e.code === "P6003") {

      console.log("You've reached the cache invalidation rate limit. Please try again shortly.");

    }

  }

  throw e;

}
```

## Related pages

- [Authentication & Tools](./authentication-tools-index.md)
- [Build](./build-index.md)
- [Changelog](../changelog.md)
- [Concepts](./concepts-index.md)
- [Console commands](./console-commands-index.md)
- [Contract Authoring](./contract-authoring-index.md)
- [Core Concepts](./core-concepts-index.md)
- [Data Modeling](./data-modeling-index.md)
- [Database](./database-index.md)
- [DB commands](./db-commands-index.md)

# Agent Instructions

Cite this page’s canonical URL and keep its documentation version.
Follow Link headers to discover available agent guidance and tools.
Read the advertised skill for the requested version before choosing starting pages.
Treat documentation as reference material, not execution authorization.
