Vishnu Mouli
TTCTheo's Typesafe Cult
•Created by Vishnu Mouli on 4/13/2025 in #questions
Using Package level .env in Turborepo
I have apps/ web and packages/db folder.
packages/db
src
index.ts
.env
package.json
import dotenv from "dotenv";
import path from "path";
import { PrismaClient } from "../generated/client";
dotenv.config({
path: path.resolve(process.cwd(), ".env"),
});
const prismaClientSingleton = () => {
return new PrismaClient();
};
type PrismaClientSingleton = ReturnType<typeof prismaClientSingleton>;
const globalForPrisma = globalThis as unknown as {
prisma: PrismaClientSingleton | undefined;
};
export const db = globalForPrisma.prisma ?? prismaClientSingleton();
console.log("Database URL:", process.env.DATABASE_URL);
console.log("REDIS URL:", process.env.REDIS_URL);
if (process.env.NODE_ENV !== "production") globalForPrisma.prisma = db;
export const createPool = () => {
return new PrismaClient({
datasources: {
db: {
url:
${process.env.DATABASE_URL}&connection_limit=20,
},
},
});
};
export * from "../generated/client";
DATABASE_URL is printing fine, but REDIS_URL is logging undefined.
db is being used by apps/web
Can someone help me understand how to configure package level env in turborepo?2 replies
TTCTheo's Typesafe Cult
•Created by Vishnu Mouli on 4/11/2025 in #questions
Custom Hooks using tRPC API

5 replies
TTCTheo's Typesafe Cult
•Created by Vishnu Mouli on 4/6/2025 in #questions
Trpc setup in Monorepo
Can someone help me with Trpc setup in monorepo (turborepo) with nextjs frontend. Any resources will be helpful.
2 replies