Open History to see the last commit
1import { createEnv } from "@t3-oss/env-core";
2import { z } from "zod";
4export const env = createEnv({
5 server: {
6 SERVER_URL: z.string().url().optional(),
7 },
9 /**
10 * The prefix that client-side variables must have. This is enforced both at
11 * a type-level and at runtime.
12 */
13 clientPrefix: "VITE_",
15 client: {
16 VITE_APP_TITLE: z.string().min(1).optional(),
17 },
19 /**
20 * What object holds the environment variables at runtime. This is usually
21 * `process.env` or `import.meta.env`.
22 */
23 runtimeEnv: import.meta.env,
25 /**
26 * By default, this library will feed the environment variables directly to
27 * the Zod validator.
28 *
29 * This means that if you have an empty string for a value that is supposed
30 * to be a number (e.g. `PORT=` in a ".env" file), Zod will incorrectly flag
31 * it as a type mismatch violation. Additionally, if you have an empty string
32 * for a value that is supposed to be a string with a default value (e.g.
33 * `DOMAIN=` in an ".env" file), the default value will never be applied.
34 *
35 * In order to solve these issues, we recommend that all new projects
36 * explicitly specify this option as true.
37 */
38 emptyStringAsUndefined: true,
39});