Using better auth & env parsed with zod causes render issues
Unanswered
aa55h posted this in #help-forum
aa55hOP
How can i solve this? what it seems like is that its trying to parse it on client side, which i dont want to happen obviously...
3 Replies
aa55hOP
import { config } from "dotenv";
import { z } from "zod";
config({ path: ".env.local" });
const env = z.object({
DATABASE_URL: z.string(),
NODE_ENV: z.optional(z.string().default(process.env.NODE_ENV)),
BETTER_AUTH_SECRET: z.string(),
BETTER_AUTH_URL: z.string(),
});
export default env.parse(process.env);this the env.ts file
Try this package replacing dotenv:
[@t3-oss/env-nextjs](https://env.t3.gg/docs/nextjs)
It fits better with nextjs and will help you with this problem.
[@t3-oss/env-nextjs](https://env.t3.gg/docs/nextjs)
It fits better with nextjs and will help you with this problem.