TanStackT
TanStack12mo ago
40 replies
ordinary-sapphire

Problem integrating T3 env in my app.

Hi, I am using tanstack start for first time and was trying to create a template for myself. I was facing problem integrating https://env.t3.gg/docs/core in my app.

env.ts
import { createEnv } from "@t3-oss/env-core";
import { z } from "zod";

export const env = createEnv({
  server: {
    TEST: z.string(),
  },
  clientPrefix: "VITE_",
  client: {
    VITE_TEST: z.string(),
  },
  runtimeEnv: process.env, // or import.meta.env or something else 
  emptyStringAsUndefined: true,
});


If I use process.env I am able to use env.TEST but env.VITE_TEST shows error. If I use import.meta.env I get env.VITE_TEST but env.TEST shows error.
What am I doing wrong.
Never build your apps with invalid environment variables again. Validate and transform your environment with the full power of Zod.
Env
Was this page helpful?