A type-compatible NextAuth.js Prisma adapter for Prisma 6, designed for projects where the Prisma client is not located at @prisma/client
.
This solves the problem with the official @next-auth/prisma-adapter
, which hardcodes an import from @prisma/client
.
In Nuxt or custom setups (e.g. when the client lives at ~/prisma/client
), that import path cannot be resolved and breaks builds.
This adapter avoids the dependency on Prisma types and lets you use your own Prisma client instance.
The adapter is primarily meant for use with @sidebase/nuxt-auth
module.
npm install @sidebase/authjs-prisma-adapter
# or
pnpm add @sidebase/authjs-prisma-adapter
// server/api/auth/[...].ts
import { PrismaAdapter } from '@sidebase/authjs-prisma-adapter'
import { NuxtAuthHandler } from '#auth'
// Import your Prisma client (can live anywhere in your project)
import { prisma } from '~/prisma/client'
export default NuxtAuthHandler({
adapter: PrismaAdapter(prisma),
// ... other configuration
})
- The official
@next-auth/prisma-adapter
directly imports from@prisma/client
. - In Nuxt or monorepo setups, Prisma 6 can be generated in a custom path (e.g.
~/prisma/client
). - That import fails, making the official adapter unusable.
This adapter re-implements the same logic from next-auth@4.21.1, but without importing @prisma/client
.
function PrismaAdapter(prisma: PrismaClient): Adapter
prisma
: Your own Prisma client instance.- Returns a NextAuth-compatible
Adapter
.
- prisma:
^6.0.0
- next-auth:
4.21.1
MIT