From 5c97a921ea8761a219106dafae8e2a68c86dba8e Mon Sep 17 00:00:00 2001 From: Florian Lefebvre Date: Thu, 15 Aug 2024 16:59:57 +0200 Subject: [PATCH] feat: update changeset --- .changeset/eighty-boxes-applaud.md | 48 +++++++++++++++++++++++++----- 1 file changed, 40 insertions(+), 8 deletions(-) diff --git a/.changeset/eighty-boxes-applaud.md b/.changeset/eighty-boxes-applaud.md index 93a8ca7f51..80d1bc07d6 100644 --- a/.changeset/eighty-boxes-applaud.md +++ b/.changeset/eighty-boxes-applaud.md @@ -2,20 +2,52 @@ 'astro': major --- -Makes `astro:env` stable +The `astro:env` feature introduced behind a flag in [v4.10.0](https://github.com/withastro/astro/blob/main/packages/astro/CHANGELOG.md#x4100) is no longer experimental and is available for general use. -To upgrade, update your Astro config: +This feature lets you configure a type-safe schema for your environment variables, and indicate whether they should be available on the server or the client. Import and use your defined variables from the appropriate `/client` or `/server` module: + +```astro +--- +import { API_URL } from "astro:env/client" +import { API_SECRET_TOKEN } from "astro:env/server" + +const data = await fetch(`${API_URL}/users`, { + method: "GET", + headers: { + "Content-Type": "application/json", + "Authorization": `Bearer ${API_SECRET_TOKEN}` + }, +}) +--- + + +``` + +If you were previously using this feature, please remove the experimental flag from your Astro config: ```diff import { defineConfig, envField } from 'astro/config' export default defineConfig({ - experimental: { - env: { - schema: { - FOO: envField.string({ /* ... */ }) - } - } +- env: { +- schema: { +- FOO: envField.string({ /* ... */ }) +- } +- } - } ++ env: { ++ schema: { ++ FOO: envField.string({ /* ... */ }) ++ } ++ } }) -``` \ No newline at end of file +``` + +If you have been waiting for stabilization before using `astro:env`, you can now do so. + +Please see [Using environment variables](https://docs.astro.build/en/guides/environment-variables/#astroenv) for more about this feature. \ No newline at end of file