UNPKG

next-validenv

Version:

Environment variable validation for Next.js

28 lines (23 loc) 768 B
// @ts-check import { validateEnvironmentVariables } from "next-validenv"; import { z } from "zod"; /** * Specify your server-side environment variables schema here. * This way you can ensure the app isn't built with invalid env vars. */ export const serverSchema = z.object({ 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_`. */ export const clientSchema = z.object({ // NEXT_PUBLIC_CLIENT: z.string(), }); const environmentVariables = validateEnvironmentVariables( clientSchema, serverSchema ); export const env = environmentVariables;