@prisma/adapter-libsql
TypeScript icon, indicating that this package has built-in type declarations

5.22.0 • Public • Published

Prisma driver adapter for libSQL

Prisma driver adapter for Turso and libSQL. Refer to the announcement blog post and our docs for more details.

Note: Support for Turso is available in Early Access from Prisma versions 5.4.2 and later.

Getting started

To get started, enable the driverAdapters Preview feature flag in your Prisma schema:

// schema.prisma
generator client {
  provider        = "prisma-client-js"
  previewFeatures = ["driverAdapters"]
}

datasource db {
  provider = "sqlite"
  url      = "file:./dev.db"
}

Generate Prisma Client:

npx prisma generate

Install the libSQL database client and Prisma driver adapter for libSQL packages:

npm install @prisma/adapter-libsql
npm install @libsql/client

Update your Prisma Client instance to use the libSQL database Client:

// Import needed packages
import { PrismaClient } from '@prisma/client'
import { PrismaLibSQL } from '@prisma/adapter-libsql'
import { createClient } from '@libsql/client'

// Setup
const connectionString = `${process.env.TURSO_DATABASE_URL}`
const authToken = `${process.env.TURSO_AUTH_TOKEN}`

// Init prisma client
const libsql = createClient({
  url: connectionString,
  authToken,
})
const adapter = new PrismaLibSQL(libsql)
const prisma = new PrismaClient({ adapter })

The above setup uses a single remote Turso database. You can take this a step further by setting up remote replicas and embedded replicas with Turso.

Refer to our docs to learn how to manage schema changes when using Prisma and Turso.

Feedback

We encourage you to create an issue if you find something missing or run into a bug.

If you have any feedback, leave a comment in this GitHub discussion.

Readme

Keywords

none

Package Sidebar

Install

npm i @prisma/adapter-libsql

Weekly Downloads

3,179

Version

5.22.0

License

Apache-2.0

Unpacked Size

35 kB

Total Files

7

Last publish

Collaborators

  • jkomyno
  • pirix-gh
  • aqrln
  • prismabot