Authentication

Quantum uses Auth.js (formerly NextAuth) for authentication.

Configuration

The main configuration is located at src/lib/auth.ts. We use a Drizzle adapter to store user sessions in your Postgres database.

import NextAuth from "next-auth"
import { DrizzleAdapter } from "@auth/drizzle-adapter"
import { db } from "@/lib/db"

export const { handlers, auth, signIn, signOut } = NextAuth({
  adapter: DrizzleAdapter(db),
  providers: [], // Add Google, GitHub here
})

Middleware

Protected routes are handled in middleware.ts. By default, the dashboard and API routes are protected.

Adding Providers

To add Google Login:

1. Get your Client ID and Secret from Google Cloud Console.

2. Add them to .env.

3. Import Google from next-auth/providers/google and add it to the providers array.