NextAuth.js Database Schema
NextAuth.js (now Auth.js) persists users, OAuth accounts, sessions, and email verification tokens in four tables: users, accounts, sessions, and verification_tokens. This diagram shows the exact columns and relationships the default Postgres adapter expects — the same shape you get from the Prisma adapter schema. A single user can have many accounts (one per OAuth provider) and many sessions.
Tables in the NextAuth.js schema
| Column | Type | Nullable | Key |
|---|---|---|---|
| users | |||
| id | text | No | PK |
| name | text | Yes | — |
| text | Yes | — | |
| emailVerified | timestamptz | Yes | — |
| image | text | Yes | — |
| accounts | |||
| id | text | No | PK |
| userId | text | No | — |
| type | text | No | — |
| provider | text | No | — |
| providerAccountId | text | No | — |
| refresh_token | text | Yes | — |
| access_token | text | Yes | — |
| expires_at | integer | Yes | — |
| token_type | text | Yes | — |
| scope | text | Yes | — |
| id_token | text | Yes | — |
| session_state | text | Yes | — |
| sessions | |||
| id | text | No | PK |
| sessionToken | text | No | — |
| userId | text | No | — |
| expires | timestamptz | No | — |
| verification_tokens | |||
| identifier | text | No | — |
| token | text | No | — |
| expires | timestamptz | No | — |
Frequently asked questions
How many tables does NextAuth.js use?
The default NextAuth.js / Auth.js database schema uses 4 tables: users, accounts, sessions, and verification_tokens.
What is the relationship between users and accounts in NextAuth?
It's a one-to-many relationship. A single user can have multiple accounts — one for each OAuth provider they sign in with (Google, GitHub, etc.). Each account row has a userId foreign key referencing users.id.
Visualize your own database
Paste your PostgreSQL connection string and get an interactive ER diagram of your own schema in under 10 seconds. No signup required.
Try it free →