Skip to content
Migrating from NextAuth.js v4? Read our migration guide.

Database Adapters

Auth.js integrations save sessions in a cookie by default. Therefore, setting up a database is optional. However, if you want to persist user information in your own database, or you want to implement certain flows, you will need to use a Database Adapter.

Database Adapters are the bridge we use to connect Auth.js to your database. For instance, when implementing magic links, the Email provider will require you to setup a database adapter to be able to store the verification tokens present on the links.

Official Adapters

Below is a list of official adapters that are distributed as their own packages under the @auth/ namespace. Their source code is available in the nextauthjs/next-auth monorepo. If you’re going to create a database adapter, please make sure you familiarise yourself with the models Auth.js expects to be present and check out our “creating a database adapter” guide.

đź’ˇ

If you don’t find an adapter for your database or service of choice, you can create one yourself. Have a look at our guide on how to create a database adapter. If you create a new adapter, we’d love it if you opened a PR to share it with everyone!

Models

This is a generic ER Diagram of what the full database schema should look like. Your database adapter of choice will include a template schema with more details for applying this schema to the underlying database. For more details, check out our database models documentation. Please note, that the entire schema is not required for every use-case, for more details check out our database adapters guide.

Auth.js © Balázs Orbán and Team - 2024