> ## Documentation Index
> Fetch the complete documentation index at: https://planetscale.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Using the PlanetScale serverless driver with Prisma

> This document outlines how you can use the [PlanetScale serverless driver](/docs/vitess/tutorials/planetscale-serverless-driver) along with Prisma in your application.

## Set up

To get started:

<Steps>
  <Step>
    Install the Prisma driver adapter for PlanetScale (`@prisma/adapter-planetscale`) and PlanetScale serverless driver (`@planetscale/database`) packages:

    ```shell theme={null}
    npm install @prisma/adapter-planetscale @planetscale/database
    ```
  </Step>

  <Step>
    Update your `prisma/schema.prisma` file:

    ```javascript theme={null}
    // schema.prisma
    generator client {
      provider = "prisma-client"
      output   = "../generated/prisma"
    }

    datasource db {
      provider     = "mysql"
      url          = env("DATABASE_URL")
      relationMode = "prisma"
    }
    ```

    <Note>
      Ensure you update the host value in your connection string to `aws.connect.psdb.cloud`. You can learn more about this [here](/vitess/tutorials/planetscale-serverless-driver#add-and-use-the-planetscale-serverless-driver-for-javascript-to-your-project).
    </Note>
  </Step>

  <Step>
    Generate Prisma Client:

    ```shell theme={null}
    npx prisma generate
    ```
  </Step>

  <Step>
    Update your Prisma Client instance to use the PlanetScale serverless driver:

    ```javascript expandable theme={null}
    import "dotenv/config"
    import { PrismaPlanetScale } from '@prisma/adapter-planetscale'
    import { PrismaClient } from './generated/prisma/client.js'

    const adapter = new PrismaPlanetScale({ url: process.env.DATABASE_URL })
    const prisma = new PrismaClient({ adapter })

    async function main() {
      const posts = await prisma.post.findMany()
      console.log(posts)
    }
    ```
  </Step>
</Steps>

You can then use Prisma Client as you usually would with auto-completion and full type-safety.

## Need help?

Get help from [the PlanetScale Support team](https://planetscale.com/contact?initial=support), or join our [Discord community](https://pscale.link/community) to see how others are using PlanetScale.
