You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/docs/en/guides/upgrade-to/v6.mdx
+56-1Lines changed: 56 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -380,19 +380,21 @@ The following experimental flags have been removed in Astro v6.0 and these featu
380
380
Additionally, the following experimental flags have been removed and **are now the default or recommended behavior in Astro v6.0**.
381
381
382
382
-`experimental.preserveScriptOrder` (See below for breaking changes to [default `<script>` and `<style>` behavior](#changed-script-and-style-tags-are-rendered-in-the-order-they-are-defined).)
383
+
-`experimental.staticImportMetaEnv` (See below for breaking changes to [`import.meta.env`](#changed-importmetaenv-values-are-always-inlined).)
383
384
384
385
The following experimental flags have been removed and **their corresponding features are not part of Astro v6.0**.
385
386
386
387
-`thing 2`
387
388
388
389
Remove these experimental flags from your Astro config if you were previously using them:
389
390
390
-
```js del={5} title="astro.config.mjs"
391
+
```js del={5-6} title="astro.config.mjs"
391
392
import { defineConfig } from'astro/config';
392
393
393
394
exportdefaultdefineConfig({
394
395
experimental: {
395
396
preserveScriptOrder:true,
397
+
staticImportMetaEnv:true,
396
398
},
397
399
})
398
400
```
@@ -498,6 +500,59 @@ Review your links to your custom endpoints that include a file extension in the
498
500
499
501
<ReadMore>Learn more about [custom endpoints](/en/guides/endpoints/).</ReadMore>
500
502
503
+
### Changed: `import.meta.env` values are always inlined
504
+
505
+
<SourcePRnumber="14485"title="feat: stabilize static import meta env"/>
506
+
507
+
In Astro 5.13, the `experimental.staticImportMetaEnv` was introduced to update the behavior when accessing `import.meta.env` directly to align with [Vite's handling of environment variables](https://vite.dev/guide/env-and-mode.html#env-variables) and ensures that `import.meta.env` values are always inlined.
508
+
509
+
In Astro 5.x, non-public environment variables were replaced by a reference to `process.env`. Additionally, Astro could also convert the value type of your environment variables used through `import.meta.env`, which could prevent access to some values such as the strings `"true"` (which was converted to a boolean value), and `"1"` (which was converted to a number).
510
+
511
+
Astro 6 removes this experimental flag and makes this the new default behavior in Astro: `import.meta.env` values are always inlined and never coerced.
512
+
513
+
#### What should I do?
514
+
515
+
If you were previously using this experimental feature, you must [remove this experimental flag from your configuration](#experimental-flags) as it no longer exists.
516
+
517
+
If you were relying on coercion, you may need to update your project code to apply it manually:
If you need more control over environment variables in Astro, we recommend you use `astro:env`.
553
+
554
+
<ReadMore>Learn more about [environment variables](/en/guides/environment-variables/) in Astro, including `astro:env`.</ReadMore>
555
+
501
556
## Community Resources
502
557
503
558
Know a good resource for Astro v5.0? [Edit this page](https://github.com/withastro/docs/edit/main/src/content/docs/en/guides/upgrade-to/v6.mdx) and add a link below!
0 commit comments