Skip to content

sidebase/authjs-prisma-adapter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@sidebase/authjs-prisma-adapter

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.

Installation

npm install @sidebase/authjs-prisma-adapter
# or
pnpm add @sidebase/authjs-prisma-adapter

Usage

// 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
})

Why not the official adapter?

  • 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.

API

function PrismaAdapter(prisma: PrismaClient): Adapter
  • prisma: Your own Prisma client instance.
  • Returns a NextAuth-compatible Adapter.

Compatibility

  • prisma: ^6.0.0
  • next-auth: 4.21.1

License

MIT

About

A Prisma 6 adapter for AuthJs

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Contributors 2

  •  
  •