You can also use NextAuth.js with the new experimental Adapter for Prisma. This version of the Prisma Adapter is not included in the core
next-auth package, and must be installed separately.
You may have noticed there is a
prisma-legacy adapter. This is due to historical reasons, but the code has mostly converged so that there is no longer much difference between the two. The legacy adapter, however, does have the ability to rename tables which the newer version does not.
To use this Adapter, you need to install Prisma Client, Prisma CLI, and the separate
Configure your NextAuth.js to use the Prisma Adapter:
While Prisma includes an experimental feature in the migration command that is able to generate SQL from a schema, creating tables and columns using the provided SQL is currently recommended instead as SQL schemas automatically generated by Prisma may differ from the recommended schemas.
Schema for the Prisma Adapter (
Create a schema file in
prisma/schema.prisma similar to this one:
Once you have saved your schema, use the Prisma CLI to generate the Prisma Client:
To configure you database to use the new schema (i.e. create tables and columns) use the
prisma migrate command:
To generate a schema in this way with the above example code, you will need to specify your database connection string in the environment variable
DATABASE_URL. You can do this by setting it in a
.env file at the root of your project.
As this feature is experimental in Prisma, it is behind a feature flag. You should check your database schema manually after using this option. See the Prisma documentation for information on how to use
Changes from the original Prisma Adapter