A ClickHouse adapter for Auth.js / NextAuth.js.
- Full Auth.js adapter implementation
- Works in any environment (Node.js, Edge, Cloudflare Workers)
- Uses the official ClickHouse HTTP client
- TypeScript support
- Zero dependencies (other than the ClickHouse client)
npm install @drivly/authjs-clickhouse @clickhouse/client-web
# or
yarn add @drivly/authjs-clickhouse @clickhouse/client-web
# or
pnpm add @drivly/authjs-clickhouse @clickhouse/client-web
Before using this adapter, you must create the required tables in your ClickHouse database. This is a one-time setup step.
- Copy the schema from schema.clickhouse.sql
- Execute the SQL statements in your ClickHouse database
The schema creates four tables:
users
- Stores user informationaccounts
- Stores OAuth account informationsessions
- Stores user sessionsverificationToken
- Stores verification tokens for email verification
import { ClickHouseClient } from '@clickhouse/client-web'
import ClickhouseAdapter from '@drivly/authjs-clickhouse'
import NextAuth from 'next-auth'
const client = new ClickHouseClient({
url: process.env.CLICKHOUSE_URL,
username: process.env.CLICKHOUSE_USER,
password: process.env.CLICKHOUSE_PASSWORD,
})
export default NextAuth({
adapter: ClickhouseAdapter(client),
// ... your NextAuth.js configuration
})
CLICKHOUSE_URL=https://your-clickhouse-host:8443
CLICKHOUSE_USER=default
CLICKHOUSE_PASSWORD=your-password
The adapter requires four tables in your ClickHouse database. These tables must be created before using the adapter:
Stores user information including email, name, and profile image.
Stores OAuth account information, linking users to their OAuth providers.
Manages active user sessions.
Handles email verification tokens.
For the complete schema definition, see schema.clickhouse.sql.
MIT