/ src / env.mjs
env.mjs
 1  import { createEnv } from "@t3-oss/env-nextjs";
 2  import { z } from "zod";
 3  
 4  export const env = createEnv({
 5    /**
 6     * Specify your server-side environment variables schema here. This way you can ensure the app
 7     * isn't built with invalid env vars.
 8     */
 9    server: {
10      NODE_ENV: z.enum(["development", "test", "production"]),
11      LIVECOINWATCH_API_KEY: z.string().min(1),
12    },
13  
14    /**
15     * Specify your client-side environment variables schema here. This way you can ensure the app
16     * isn't built with invalid env vars. To expose them to the client, prefix them with
17     * `NEXT_PUBLIC_`.
18     */
19    client: {
20      // NEXT_PUBLIC_CLIENTVAR: z.string(),
21    },
22  
23    /**
24     * You can't destruct `process.env` as a regular object in the Next.js edge runtimes (e.g.
25     * middlewares) or client-side so we need to destruct manually.
26     */
27    runtimeEnv: {
28      NODE_ENV: process.env.NODE_ENV,
29      LIVECOINWATCH_API_KEY: process.env.LIVECOINWATCH_API_KEY,
30      // NEXT_PUBLIC_CLIENTVAR: process.env.NEXT_PUBLIC_CLIENTVAR,
31    },
32    /**
33     * Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation.
34     * This is especially useful for Docker builds.
35     */
36    skipValidation: !!process.env.SKIP_ENV_VALIDATION,
37    /**
38     * Makes it so that empty strings are treated as undefined.
39     * `SOME_VAR: z.string()` and `SOME_VAR=''` will throw an error.
40     */
41    emptyStringAsUndefined: true,
42  });