From dbb43c5d888a64a8b2d4745187d467fd3089e135 Mon Sep 17 00:00:00 2001 From: Jakub Jablonski Date: Sun, 7 May 2023 22:04:03 +0200 Subject: [PATCH] docs: add instruction for t3 env to readme --- README.md | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ee9a29e..f39a864 100644 --- a/README.md +++ b/README.md @@ -227,8 +227,30 @@ To use ChatGPT Code Review, add an `OPENAI_API_KEY` environment variable with an [T3 Env](https://env.t3.gg/) is a library that provides environmental variables checking at build time, type validation and transforming. It ensures that your application is using the correct environment variables and their values are of the expected type. You’ll never again struggle with runtime errors caused by incorrect environment variable usage. +Config file is located at `env.mjs`. Simply set your client and server variables and import `env` from any file in your project. + +```ts +export const env = createEnv({ + server: { + // Server variables + SECRET_KEY: z.string(), + }, + client: { + // Client variables + API_URL: z.string().url(), + }, + runtimeEnv: { + // Assign runtime variables + SECRET_KEY: process.env.SECRET_KEY, + API_URL: process.env.NEXT_PUBLIC_API_URL, + }, +}) +``` + +If the required environment variables are not set, you'll get an error message: + ```sh - ❌ Invalid environment variables: { ANALYZE: [ 'Required' ] } + ❌ Invalid environment variables: { SECRET_KEY: [ 'Required' ] } ``` ## 🤝 Contribution