diff --git a/docs/pages/getting-started/adapters/drizzle.mdx b/docs/pages/getting-started/adapters/drizzle.mdx index fad55d0b83..c0f6e9b695 100644 --- a/docs/pages/getting-started/adapters/drizzle.mdx +++ b/docs/pages/getting-started/adapters/drizzle.mdx @@ -54,7 +54,7 @@ import { } from "drizzle-orm/pg-core" import postgres from "postgres" import { drizzle } from "drizzle-orm/postgres-js" -import type { AdapterAccountType } from "@auth/core/adapters" +import type { AdapterAccountType } from "next-auth/adapters" const connectionString = "postgres://postgres:postgres@localhost:5432/drizzle" const pool = postgres(connectionString, { max: 1 }) @@ -130,7 +130,7 @@ import { } from "drizzle-orm/mysql-core" import mysql from "mysql2/promise" import { drizzle } from "drizzle-orm/mysql2" -import type { AdapterAccountType } from "@auth/core/adapters" +import type { AdapterAccountType } from "next-auth/adapters" export const connection = await mysql.createConnection({ host: "host", @@ -209,7 +209,7 @@ If you want to modify the schema or add additional fields, you can use the follo import { integer, sqliteTable, text, primaryKey } from "drizzle-orm/sqlite-core" import { createClient } from "@libsql/client" import { drizzle } from "drizzle-orm/libsql" -import type { AdapterAccountType } from "@auth/core/adapters" +import type { AdapterAccountType } from "next-auth/adapters" const client = createClient({ url: "DATABASE_URL", @@ -328,6 +328,30 @@ app.use( +#### Passing your own Schemas + +If you want to use your own tables, you can pass them as a second argument to `DrizzleAdapter`. + +- The `sessionsTable` is optional and only required if you're using the database session strategy. +- The `verificationTokensTable` is optional and only required if you're using a Magic Link provider. + +```ts filename="auth.ts" +import NextAuth from "next-auth" +import Google from "next-auth/providers/google" +import { DrizzleAdapter } from "@auth/drizzle-adapter" +import { db, accounts, sessions, users, verificationTokens } from "./schema" + +export const { handlers, auth } = NextAuth({ + adapter: DrizzleAdapter(db, { + usersTable: users, + accountsTable: accounts, + sessionsTable: sessions, + verificationTokensTable: verificationTokens, + }), + providers: [Google], +}) +``` + ### Migrating your database With your schema now described in your code, you'll need to migrate your database to your schema. An example `migrate.ts` file looks like this. For more information, check out Drizzle's migration [quick start guide](https://orm.drizzle.team/docs/migrations). diff --git a/docs/pages/getting-started/adapters/typeorm.mdx b/docs/pages/getting-started/adapters/typeorm.mdx index 01483bbda1..03a1e429cf 100644 --- a/docs/pages/getting-started/adapters/typeorm.mdx +++ b/docs/pages/getting-started/adapters/typeorm.mdx @@ -83,7 +83,7 @@ You can override the default entities and add additional fields with a custom en 1. Create a file containing your modified entities: -```ts filename="lib/entities.ts" +```ts filename="lib/entities.ts" {38-39} import { Entity, PrimaryGeneratedColumn, diff --git a/docs/pages/getting-started/adapters/upstash-redis.mdx b/docs/pages/getting-started/adapters/upstash-redis.mdx index 8ac8dd39f2..6f87915113 100644 --- a/docs/pages/getting-started/adapters/upstash-redis.mdx +++ b/docs/pages/getting-started/adapters/upstash-redis.mdx @@ -122,7 +122,7 @@ const defaultOptions = { Usually changing the `baseKeyPrefix` should be enough for this scenario, but for more custom setups, you can also change the prefixes of every single key. ```ts -export default NextAuth({ +export const { handlers, auth, signIn, signOut } = NextAuth({ adapter: UpstashRedisAdapter(redis, { baseKeyPrefix: "app2:" }), }) ```