diff options
Diffstat (limited to 'benchmark/frontend/src/env.mjs')
-rw-r--r-- | benchmark/frontend/src/env.mjs | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/benchmark/frontend/src/env.mjs b/benchmark/frontend/src/env.mjs new file mode 100644 index 000000000..22b22581d --- /dev/null +++ b/benchmark/frontend/src/env.mjs @@ -0,0 +1,37 @@ +import { createEnv } from "@t3-oss/env-nextjs"; +import { z } from "zod"; + +export const env = createEnv({ + /** + * Specify your server-side environment variables schema here. This way you can ensure the app + * isn't built with invalid env vars. + */ + server: { + // DATABASE_URL: z.string().url(), + NODE_ENV: z.enum(["development", "test", "production"]), + }, + + /** + * Specify your client-side environment variables schema here. This way you can ensure the app + * isn't built with invalid env vars. To expose them to the client, prefix them with + * `NEXT_PUBLIC_`. + */ + client: { + // NEXT_PUBLIC_CLIENTVAR: z.string().min(1), + }, + + /** + * You can't destruct `process.env` as a regular object in the Next.js edge runtimes (e.g. + * middlewares) or client-side so we need to destruct manually. + */ + runtimeEnv: { + // DATABASE_URL: process.env.DATABASE_URL, + NODE_ENV: process.env.NODE_ENV, + // NEXT_PUBLIC_CLIENTVAR: process.env.NEXT_PUBLIC_CLIENTVAR, + }, + /** + * Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. + * This is especially useful for Docker builds. + */ + skipValidation: !!process.env.SKIP_ENV_VALIDATION, +}); |