@custom-auth/drizzle
v1.0.11
Published
Drizzle ORM database adapter for @custom-auth.
Maintainers
Readme
@custom-auth/drizzle
📦 Ecosystem Packages
- 🔑 Core Engine (@custom-auth/core) — The core framework-agnostic auth engine.
- ⚛️ React SDK (@custom-auth/react) — React hooks and context provider.
- 🌐 Next.js SDK (@custom-auth/nextjs) — Edge-compatible Next.js helpers and middleware.
- 🗄️ Database Adapters:
- ✉️ Email Adapters:
The official Drizzle ORM adapter for @custom-auth.
Installation
# Install the core engine, the Drizzle adapter, and your chosen email adapter
npm install @custom-auth/core @custom-auth/drizzle <your-email-adapter>Quick Start
import { CustomAuth } from '@custom-auth/core';
import { DrizzleAdapter } from '@custom-auth/drizzle';
import { db } from './db'; // Your initialized Drizzle db instance
export const auth = new CustomAuth({
db: new DrizzleAdapter(db),
// ...other config
});Schema Setup
Drizzle requires you to export the provided schema tables so they can be pushed to your database.
Step 1 — Use the built-in schema (or extend it)
// db/schema.ts
export {
usersTable,
sessionsTable,
verificationTokensTable,
} from '@custom-auth/drizzle/schema';
// Or extend to add custom columns:
import { usersTable as base } from '@custom-auth/drizzle/schema';
import { pgTable, text } from 'drizzle-orm/pg-core';
export const usersTable = pgTable('auth_users', {
...base, // id, email, name, passwordHash, role, emailVerified, createdAt, updatedAt
stripeCustomerId: text('stripe_customer_id'),
plan: text('plan').notNull().default('free'),
});Step 2 — Push schema
npx drizzle-kit push:pgDocumentation
For full documentation, please visit the Main Repository.
