Commit bf7c4e2
docs: clarify functionality of
I spent a lot of time trying to understand the `$env/* variables and how
they behave, the docs didn't really seem very fleshed out and I was
confused. I wrote up a bunch of demo code to make sure I really
understood the behaviour, and then realized that a little love in the
docs would probably be appreciated.
All sample code has been run locally and validated as correct as of
`svelte@5.45.6` (using the `npx sv create` to make a minimal app).
Anything that required validation between dev and prod I ran `npm run
build`, editing the `.env` file as necessary, and then `npm run preview`
to run.
## The overall idea
Here's how I broke it down conceptually:
| | Runtime | Buildtime |
|-|-|-|
| Private |
[`$env/dynamic/private`](https://svelte.dev/docs/kit/$env-dynamic-private)
|
[`$env/static/private`](https://svelte.dev/docs/kit/$env-static-private)
|
| Public |
[`$env/dynamic/public`](https://svelte.dev/docs/kit/$env-dynamic-public)
| [`$env/static/public`](https://svelte.dev/docs/kit/$env-static-public)
|
Private versus public:
- Whether or not it can be imported into client-side code.
- Filtering variables based on the `publicPrefix`/`privatePrefix`.
Runtime versus buildtime:
- Whether or not values change based on platform specifics.
- Whether variables make their way into bundled code.
---
### Please don't delete this checklist! Before submitting the PR, please
make sure you do the following:
- ~~[ ] It's really useful if your PR references an issue where it is
discussed ahead of time. In many cases, features are absent for a
reason. For large changes, please create an RFC:
https://github.com/sveltejs/rfcs~~
- Could not find an open issue about this,
- [x] This message body should clearly illustrate what problems it
solves.
- ~~[ ] Ideally, include a test that fails without this PR but passes
with it.~~
- This PR is documentation only.
### Tests
- ~~[ ] Run the tests with `pnpm test` and lint the project with `pnpm
lint` and `pnpm check`~~
- This PR is documentation only, hopefully I don't need to do this 😅
### Changesets
- ~~[ ] If your PR makes a change that should be noted in one or more
packages' changelogs, generate a changeset by running `pnpm changeset`
and following the prompts. Changesets that add features should be
`minor` and those that fix bugs should be `patch`. Please prefix
changeset messages with `feat:`, `fix:`, or `chore:`.~~
- I don't think this needs to appear in a changelog.
### Edits
- [x] Please ensure that 'Allow edits from maintainers' is checked. PRs
without this option may be closed.
---------
Co-authored-by: Elliott Johnson <elliott.johnson@vercel.com>
Co-authored-by: Tee Ming <chewteeming01@gmail.com>
Co-authored-by: Elliott Johnson <hello@ell.iott.dev>$env/* variables (sveltejs#15078)1 parent 04336fc commit bf7c4e2
File tree
5 files changed
+130
-22
lines changed- .github/workflows
- packages/kit/src/types/synthetic
5 files changed
+130
-22
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
4 | 37 | | |
5 | 38 | | |
6 | 39 | | |
7 | | - | |
8 | | - | |
9 | 40 | | |
10 | | - | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
4 | 37 | | |
5 | 38 | | |
6 | 39 | | |
7 | | - | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
8 | 46 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
4 | 7 | | |
5 | | - | |
6 | | - | |
7 | | - | |
| 8 | + | |
8 | 9 | | |
9 | | - | |
| 10 | + | |
10 | 11 | | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
11 | 20 | | |
12 | | - | |
13 | | - | |
14 | 21 | | |
15 | | - | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
16 | 26 | | |
17 | | - | |
18 | | - | |
| 27 | + | |
| 28 | + | |
19 | 29 | | |
| 30 | + | |
| 31 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
4 | 23 | | |
5 | 24 | | |
6 | | - | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
7 | 29 | | |
| 30 | + | |
| 31 | + | |
0 commit comments