{"record":{"id":"322d12660b78e69e","repo":"nextauthjs/next-auth","slug":"unsupported-database-type-typeof-db-in-auth-j","errorCode":null,"errorMessage":"Unsupported database type (${typeof db}) in Auth.js Drizzle adapter.","messagePattern":"Unsupported database type \\((.+?)\\) in Auth\\.js Drizzle adapter\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/adapter-drizzle/src/index.ts","lineNumber":42,"sourceCode":"import { DefaultPostgresSchema, PostgresDrizzleAdapter } from \"./lib/pg.js\"\nimport { DefaultSQLiteSchema, SQLiteDrizzleAdapter } from \"./lib/sqlite.js\"\nimport { DefaultSchema, SqlFlavorOptions } from \"./lib/utils.js\"\n\nimport type { Adapter } from \"@auth/core/adapters\"\n\nexport function DrizzleAdapter<SqlFlavor extends SqlFlavorOptions>(\n  db: SqlFlavor,\n  schema?: DefaultSchema<SqlFlavor>\n): Adapter {\n  if (is(db, MySqlDatabase)) {\n    return MySqlDrizzleAdapter(db, schema as DefaultMySqlSchema)\n  } else if (is(db, PgDatabase)) {\n    return PostgresDrizzleAdapter(db, schema as DefaultPostgresSchema)\n  } else if (is(db, BaseSQLiteDatabase)) {\n    return SQLiteDrizzleAdapter(db, schema as DefaultSQLiteSchema)\n  }\n\n  throw new Error(\n    `Unsupported database type (${typeof db}) in Auth.js Drizzle adapter.`\n  )\n}\n","sourceCodeStart":24,"sourceCodeEnd":46,"githubUrl":"https://github.com/nextauthjs/next-auth/blob/a1a16a5a7780488c7449feece410033f445d0b31/packages/adapter-drizzle/src/index.ts#L24-L46","documentation":"DrizzleAdapter accepts a driver-agnostic drizzle instance and uses instanceof checks (is(db, PgDatabase), BaseSQLiteDatabase, etc.) to dispatch to the right dialect-specific adapter. If the passed object matches none of the known database classes, it throws this error. The typeof db in the message shows the JS type of what you actually passed, which is the main debugging clue.","triggerScenarios":"Passing something that is not a drizzle database instance: a plain connection string, a raw driver client (e.g. mysql2 pool, postgres.js sql), a Neon/HTTP client not wrapped in drizzle, or an incompatible drizzle version where instanceof checks fail.","commonSituations":"Forgetting to wrap the driver with drizzle() (e.g. passing postgres(sql) instead of drizzle(sql)), duplicating drizzle-orm versions so instanceof fails across package instances, or passing a mysql2 connection directly.","solutions":["Wrap your driver in drizzle() before passing it: DrizzleAdapter(drizzle(postgres(url))).","Deduplicate drizzle-orm so only one copy is installed (npm ls drizzle-orm; dedupe/overrides) — multiple copies break instanceof checks.","Pass the correct instance for your dialect (PgDatabase, MySqlDatabase, BaseSQLiteDatabase).","Check the typeof value in the error message; 'string' means you passed the connection URL directly."],"exampleFix":"// before\nconst adapter = DrizzleAdapter('postgres://user:pass@localhost/db')\n// after\nimport { drizzle } from 'drizzle-orm/postgres-js'\nimport postgres from 'postgres'\nconst adapter = DrizzleAdapter(drizzle(postgres('postgres://user:pass@localhost/db')))","handlingStrategy":"type-guard","validationCode":"import { is } from 'drizzle-orm'\nimport { PgDatabase } from 'drizzle-orm/pg-core'\nif (!is(db, PgDatabase)) throw new Error('DrizzleAdapter requires a drizzle() database instance')","typeGuard":"function isDrizzleDb(db: unknown): db is PgDatabase {\n  return is(db, PgDatabase)\n}","tryCatchPattern":"try {\n  const adapter = DrizzleAdapter(db)\n} catch (e) {\n  if (e instanceof Error && e.message.includes('Unsupported database type')) {\n    // typeof in message tells you what you passed; wrap driver in drizzle() or dedupe drizzle-orm\n  }\n  throw e\n}","preventionTips":["Always wrap raw drivers with drizzle() before passing to DrizzleAdapter","Ensure a single drizzle-orm version (npm ls drizzle-orm; dedupe)","Read the typeof in the error message to diagnose what was actually passed","Match the adapter import to your dialect (pg-core, mysql-core, sqlite-core)"],"tags":["configuration","typescript","drizzle","initialization"],"backgroundTag":"invalid-argument-type","analyzedSha":"a1a16a5a7780488c7449feece410033f445d0b31","analyzedAt":"2026-08-28T21:52:38.200Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}