Drizzle running on Tanstack pages that don't even call the db,
After migrating from prisma to drizzle I was forced to import "server-only" in my db file:
import "server-only";
import { drizzle } from "drizzle-orm/neon-http";
import * as schema from "./schema";
import * as relations from "./relations";
export const db = drizzle(process.env.DATABASE_URL!, {
schema: { ...schema, ...relations },
});
Because i was seeing errors like:
Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'query')
This error was appearing even in pages with no db calls. This makes me conclude that some weird thing is happening and calling the db but I cannot figure out what... I even isolated every file that calls the db so that files that contain a serverFn that calls the db ONLY contain server code but this still did not fix the issue. Anyone has any ideas on how to fix this?
0 Replies