0.1.0 • Published 1 year ago

authjs-adapter-mysql v0.1.0

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

CI


This adapter uses mysql statements to integrate with Authjs.

PlanetScale is supported with Mysql2 or the serverless driver.

How to use with Mysql2

Install:

npm i authjs-adapter-mysql mysql2

use schema.sql to create the tables.

import MysqlAdapter from "authjs-adapter-mysql";
import * as mysql from "mysql2/promise";
import buildMysqlHelpers from "authjs-adapter-mysql/dist/mysql";

function getConnection() {
  return mysql.createConnection({
    host: "127.0.0.1",
    user: "root",
    database: "fancydb",
  });
}

// you can create your own helpers for custom logic
const mysqlHelpers = buildMysqlHelpers(getConnection);

export default NextAuth({
  adapter: MysqlAdapter(mysqlHelpers),
  providers: [],
});

When using the new app dir in NextJs you may need this:

const nextConfig = {
  experimental: {
    appDir: true,
    serverComponentsExternalPackages: ["mysql2"],
  },
};

How to use with PlanetScale serverless driver

Install:

npm i authjs-adapter-mysql @planetscale/database

use schema.sql to create the tables.

import MysqlAdapter from "authjs-adapter-mysql";
import buildPlanetScaleHelpers from "authjs-adapter-mysql/dist/planetscale";

const client = new Client(config);

// you can create your own helpers for custom logic
const psHelpers = buildPlanetScaleHelpers(client);

export default NextAuth({
  adapter: MysqlAdapter(psHelpers),
  providers: [],
});
0.1.0

1 year ago

0.0.9

1 year ago

0.0.8

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago