* feat: move adapters repo to new packages dir * fix: rm docusaurus build dir * fix: update .gitignore * fix: reorganise package directories * remove package lock files * fix: folder rename * remove package lock file * fix: jest config paths * update yarn.lock * ignore dynamodb local bin * fix: gitignore * fix: update adapter-test * change adapter-test package json * rename prisma adapter package name * fix paths * update gitignore * run tests with one concurrency * fix: merge conflicts * gitignore dist folders * fix: add jest.config.js to tsconfig ignore * fix: yarn.lock * fix: ignore pouch in turbo commands * ignore jest file * fix: test turbo test cmd * fix: turbo test cmd * test: disable mongodb-adapter temporarily * ignore all dev.db files * simplify gitignore * remove unused dependency * have tsconfig in its own package * remove unnecessary .gitignore files * move jest config to preset * add ts expect error comment * chore: update .gitignore * remove babelrc * don't depend on build for testing in turbo * fix: cleanup testing npm scripts * fix: remove jest-config roots * fix: add fauna jest preset * fix: rm dev.db from prisma mirgation * fix prisma * remove nohoist Co-authored-by: Balázs Orbán <info@balazsorban.com>
Sequelize Adapter - NextAuth.js
Open Source. Full Stack. Own Your Data.
Overview
This is the Sequelize Adapter for next-auth. This package can only be used in conjunction with the primary next-auth package. It is not a standalone package.
You can find the Sequelize schema in the docs at next-auth.js.org/adapters/sequelize.
Getting Started
- Install
next-authand@next-auth/sequelize-adapteras well assequelizeand your database driver of choice.
npm install next-auth @next-auth/sequelize-adapter sequelize sqlite3
npm install --save-dev sequelize
- Add this adapter to your
pages/api/[...nextauth].jsnext-auth configuration object.
import NextAuth from "next-auth"
import SequelizeAdapter from "@next-auth/sequelize-adapter"
import Sequelize from 'sequelize'
const sequelize = new Sequelize("sqlite::memory:")
// For more information on each option (and a full list of options) go to
// https://next-auth.js.org/configuration/options
export default NextAuth({
...
adapter: SequelizeAdapter(sequelize)
...
})
Updating the database schema
In development, the sequelize adapter will create the necessary tables, foreign keys and indexes in your database. In production, synchronization is disabled. Best practice is to create the required tables in your database via migrations.
In development, if you do not want the adapter to automatically create tables, you are able to pass { synchronize: false } as the second option to SequelizeAdapter to disable this behavior:
import NextAuth from "next-auth"
import SequelizeAdapter from "@next-auth/sequelize-adapter"
import Sequelize from 'sequelize'
const sequelize = new Sequelize("sqlite::memory:")
export default NextAuth({
...
adapter: SequelizeAdapter(sequelize, { synchronize: false })
...
})
Using custom models
Sequelize models are option to customization like so:
import NextAuth from "next-auth"
import SequelizeAdapter, { models } from "@next-auth/sequelize-adapter"
import Sequelize, { DataTypes } from 'sequelize'
const sequelize = new Sequelize("sqlite::memory:")
export default NextAuth({
...
adapter: SequelizeAdapter(sequelize, {
models: {
User: sequelize.define('user', { ...models.User, phoneNumber: DataTypes.STRING })
}
})
...
})
Contributing
We're open to all community contributions! If you'd like to contribute in any way, please read our Contributing Guide.
License
ISC
