-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: improve astro:env docs #11653
Conversation
🦋 Changeset detectedLatest commit: 56b72df The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
* | ||
* The `astro:env` API 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 { APP_ID } from "astro:env/client" | ||
* import { API_URL, API_TOKEN, getSecret } from "astro:env/server" | ||
* const NODE_ENV = getSecret("NODE_ENV") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removes getSecret from the first snippet so that people do not assume it's the only way to access them (+ it's an advanced uscase)
* }) | ||
* --- | ||
* | ||
* <script> | ||
* import { API_URL } from "astro:env/client" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also showing in a client script so users understand a client var can be accessed on both client and server
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Thank you for updating @florian-lefebvre ! 🥳
Co-authored-by: Sarah Rainsberger <[email protected]>
Changes
N/A
Testing
N/A
Docs
Yes