Next.js Discord

Discord Forum

Next-Auth v5 with create-t3-turbo and KyselyAdapter fails

Unanswered
Cooper's Hawk posted this in #help-forum
Open in Discord
Cooper's HawkOP
Hello, I've installed a blank new and fresh create-t3-turbo template, switched drizzle to prisma-kysely etc. But when I try to connect the KyselyAdapter to my NextAuth Config I am always getting following error

7 Replies

Cooper's HawkOP
This is the error:
This is the auth.db.ts file:

// This adapter exports a wrapper of the original `Kysely` class called `KyselyAuth`,
// that can be used to provide additional type-safety.
// While using it isn't required, it is recommended as it will verify
// that the database interface has all the fields that Auth.js expects.
import type { Codegen } from "@auth/kysely-adapter";
import type { GeneratedAlways } from "kysely";
import { KyselyAuth } from "@auth/kysely-adapter";
import { Kysely, PostgresDialect } from "kysely";
import { Pool } from "pg";

export interface Database {
  User: {
    id: GeneratedAlways<string>;
    name: string | null;
    email: string;
    emailVerified: Date | null;
    image: string | null;
  };
  Account: {
    id: GeneratedAlways<string>;
    userId: string;
    type: string;
    provider: string;
    providerAccountId: string;
    refresh_token: string | null;
    access_token: string | null;
    expires_at: number | null;
    token_type: string | null;
    scope: string | null;
    id_token: string | null;
    session_state: string | null;
  };
  Session: {
    id: GeneratedAlways<string>;
    userId: string;
    sessionToken: string;
    expires: Date;
  };
  VerificationToken: {
    identifier: string;
    token: string;
    expires: Date;
  };
}

export const db = new Kysely<Database>({
  dialect: new PostgresDialect({
    pool: new Pool({
      connectionString: process.env.POSTGRES_URL,
    }),
  }),
});
I'm using following dependencies:

  "dependencies": {
    "@acme/db": "workspace:*",
    "@auth/core": "0.34.2",
    "@auth/drizzle-adapter": "^1.4.2",
    "@auth/kysely-adapter": "^1.6.0",
    "@t3-oss/env-nextjs": "^0.11.1",
    "kysely": "^0.26.1",
    "next": "^14.2.5",
    "next-auth": "5.0.0-beta.22",
    "pg": "^8.13.0",
    "react": "catalog:react18",
    "react-dom": "catalog:react18",
    "zod": "catalog:"
  },
  "devDependencies": {
    "@acme/eslint-config": "workspace:*",
    "@acme/prettier-config": "workspace:*",
    "@acme/tsconfig": "workspace:*",
    "@types/pg": "^8.11.10",
    "eslint": "catalog:",
    "prettier": "catalog:",
    "typescript": "catalog:"
  },
Also, since I changed the DrizzleAdapter to KyselyAdapter, I'm keep getting this nextjs error:

Note: I have commented out export const runtime = "edge"; everywhere
Cooper's HawkOP
The issue now has a stackoverflow thread