Skip to content

Commit 09a3691

Browse files
committed
chore(docs): cleanup Drizzle adapter doc page
1 parent aecc221 commit 09a3691

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

docs/pages/getting-started/adapters/drizzle.mdx

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ import {
5454
} from "drizzle-orm/pg-core"
5555
import postgres from "postgres"
5656
import { drizzle } from "drizzle-orm/postgres-js"
57-
import type { AdapterAccountType } from "@auth/core/adapters"
57+
import type { AdapterAccountType } from "next-auth/adapters"
5858

5959
const connectionString = "postgres://postgres:postgres@localhost:5432/drizzle"
6060
const pool = postgres(connectionString, { max: 1 })
@@ -130,7 +130,7 @@ import {
130130
} from "drizzle-orm/mysql-core"
131131
import mysql from "mysql2/promise"
132132
import { drizzle } from "drizzle-orm/mysql2"
133-
import type { AdapterAccountType } from "@auth/core/adapters"
133+
import type { AdapterAccountType } from "next-auth/adapters"
134134

135135
export const connection = await mysql.createConnection({
136136
host: "host",
@@ -209,7 +209,7 @@ If you want to modify the schema or add additional fields, you can use the follo
209209
import { integer, sqliteTable, text, primaryKey } from "drizzle-orm/sqlite-core"
210210
import { createClient } from "@libsql/client"
211211
import { drizzle } from "drizzle-orm/libsql"
212-
import type { AdapterAccountType } from "@auth/core/adapters"
212+
import type { AdapterAccountType } from "next-auth/adapters"
213213

214214
const client = createClient({
215215
url: "DATABASE_URL",
@@ -328,6 +328,30 @@ app.use(
328328
</Code.Express>
329329
</Code>
330330

331+
#### Passing your own Schemas
332+
333+
If you want to use your own tables, you can pass them as a second argument to `DrizzleAdapter`.
334+
335+
- The `sessionsTable` is optional and only required if you're using the database session strategy.
336+
- The `verificationTokensTable` is optional and only required if you're using a Magic Link provider.
337+
338+
```ts filename="auth.ts"
339+
import NextAuth from "next-auth"
340+
import Google from "next-auth/providers/google"
341+
import { DrizzleAdapter } from "@auth/drizzle-adapter"
342+
import { db, accounts, sessions, users, verificationTokens } from "./schema"
343+
344+
export const { handlers, auth } = NextAuth({
345+
adapter: DrizzleAdapter(db, {
346+
usersTable: users,
347+
accountsTable: accounts,
348+
sessionsTable: sessions,
349+
verificationTokensTable: verificationTokens,
350+
}),
351+
providers: [Google],
352+
})
353+
```
354+
331355
### Migrating your database
332356

333357
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).

0 commit comments

Comments
 (0)