Skip to content

Commit a8a3b14

Browse files
DreaminDanibluwy
andauthored
Update 60-env-vars.md (#4013)
* Update 60-env-vars.md VITE doesn't use `process.` it's `import.meta` * docs: explain import meta env Co-authored-by: Bjorn Lu <[email protected]>
1 parent a9daeec commit a8a3b14

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Diff for: documentation/faq/60-env-vars.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: How do I use environment variables?
33
---
44

5-
Vite uses [dotenv](https://github.com/motdotla/dotenv) to load environment variables from a file named `.env` or similar. Only environment variables prefixed with `VITE_` are exposed ([you can set `envPrefix` to change this](https://vitejs.dev/config/#envprefix)). Vite will use these and statically replace them at build-time.
5+
Vite uses [dotenv](https://github.com/motdotla/dotenv) to load environment variables from a file named `.env` or similar. Only environment variables prefixed with `VITE_` are exposed ([you can set `envPrefix` to change this](https://vitejs.dev/config/#envprefix)). You can access the variable using `import.meta.env.VITE_ENV_VAR`, and Vite will statically replace them at build-time.
66

77
To use environment variables at runtime, you would need to instantiate dotenv yourself in your server-side code so that they are exposed at `process.env.YOUR_ENV_VAR`. You may also use `$session` to pass them to the client if needed.
88

0 commit comments

Comments
 (0)