© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Team•7mo ago•
1 reply
steezus

Turborepo - no type safety when using drizzle in other modules

Hi all, I am setting up a monorepo with turborepo where I have an API under
apps/api
apps/api
and a database module under
packages/db
packages/db
. I am losing type safety when importing the
db
db
instance in another package. I export all of my tables and the drizzle instance like so below:

// packages/db/src/index.ts
import "@dotenvx/dotenvx";
import { drizzle } from "drizzle-orm/libsql";
import * as schema from "./schemas"; // barrel file to export all schemas and types

if (!process.env.DATABASE_URL) {
    throw new Error("DATABASE_URL not set");
}

export const db = drizzle({
    connection: {
        url: process.env.DATABASE_URL,
        authToken: process.env.AUTH_TOKEN,
    },
    schema,
});
export * from "drizzle-orm";
export * from "./schemas";
// packages/db/src/index.ts
import "@dotenvx/dotenvx";
import { drizzle } from "drizzle-orm/libsql";
import * as schema from "./schemas"; // barrel file to export all schemas and types

if (!process.env.DATABASE_URL) {
    throw new Error("DATABASE_URL not set");
}

export const db = drizzle({
    connection: {
        url: process.env.DATABASE_URL,
        authToken: process.env.AUTH_TOKEN,
    },
    schema,
});
export * from "drizzle-orm";
export * from "./schemas";


I am not sure if this is a problem with my tsconfig for both of these modules or how I am exporting packages.

I attached screenshots of what my IDE displays when I hover over users and what the returned value should be. Any help would be appreciated, thank you 🙏
Screenshot_2025-07-16_at_12.30.28_AM.png
Screenshot_2025-07-16_at_12.34.52_AM.png
Drizzle TeamJoin
The official Discord for all Drizzle related projects, such as Drizzle ORM, Drizzle Kit, Drizzle Studio and more!
11,879Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Drizzle in Turborepo
Drizzle TeamDTDrizzle Team / help
10mo ago
Type Error When Using ...companies in Drizzle ORM select()
Drizzle TeamDTDrizzle Team / help
11mo ago
Using Drizzle as a package in Turborepo doesn't work ?
Drizzle TeamDTDrizzle Team / help
3y ago
Exploring Type Safety in Drizzle: Does Zod Enhance or Redundantly Overlap?
Drizzle TeamDTDrizzle Team / help
2y ago