diff --git a/.changeset/good-rabbits-exercise.md b/.changeset/good-rabbits-exercise.md new file mode 100644 index 0000000..0964a26 --- /dev/null +++ b/.changeset/good-rabbits-exercise.md @@ -0,0 +1,5 @@ +--- +"@t3-oss/env-core": patch +--- + +add netlify preset diff --git a/docs/src/app/docs/customization/page.mdx b/docs/src/app/docs/customization/page.mdx index 6cfb248..a76a7b7 100644 --- a/docs/src/app/docs/customization/page.mdx +++ b/docs/src/app/docs/customization/page.mdx @@ -102,6 +102,7 @@ T3 Env ships the following presets out of the box, all importable from the `/pre - `render` - Render environment variables. See full list [here](https://docs.render.com/environment-variables#all-runtimes). - `railway` - Railway provided system environment variables. See full list [here](https://docs.railway.app/reference/variables#railway-provided-variables). - `fly.io` - Fly.io provided machine runtime environment variables. See full list [here](https://fly.io/docs/machines/runtime-environment/#environment-variables). +- `netlify` - Netlify provided system environment variables. See full list [here](https://docs.netlify.com/configure-builds/environment-variables). Feel free to open a PR with more presets! diff --git a/packages/core/src/presets.ts b/packages/core/src/presets.ts index dc843f9..6f4d5a0 100644 --- a/packages/core/src/presets.ts +++ b/packages/core/src/presets.ts @@ -161,3 +161,27 @@ export const fly = () => }, runtimeEnv: process.env, }); + +/** + * Netlify Environment Variables + * @see https://docs.netlify.com/configure-builds/environment-variables + */ +export const netlify = () => + createEnv({ + server: { + NETLIFY: z.string().optional(), + BUILD_ID: z.string().optional(), + CONTEXT: z + .enum(["production", "deploy-preview", "branch-deploy", "dev"]) + .optional(), + REPOSITORY_URL: z.string().optional(), + BRANCH: z.string().optional(), + URL: z.string().optional(), + DEPLOY_URL: z.string().optional(), + DEPLOY_PRIME_URL: z.string().optional(), + DEPLOY_ID: z.string().optional(), + SITE_NAME: z.string().optional(), + SITE_ID: z.string().optional(), + }, + runtimeEnv: process.env, + });