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
This module provides access to runtime environment variables, as defined by the platform you're running on. For example if you're using [`adapter-node`](https://github.com/sveltejs/kit/tree/master/packages/adapter-node) (or running [`vite preview`](https://kit.svelte.dev/docs/cli)), this is equivalent to `process.env`. This module only includes variables that _do not_ begin with [`config.kit.env.publicPrefix`](https://kit.svelte.dev/docs/configuration#kit-env-publicprefix).
2
+
3
+
This module cannot be imported into client-side code.
Similar to [`$env/dynamic/private`](https://kit.svelte.dev/docs/modules#$env-dynamic-private), but only includes variables that begin with [`config.kit.env.publicPrefix`](https://kit.svelte.dev/docs/configuration#kit-env-publicprefix) (which defaults to `PUBLIC_`), and can therefore safely be exposed to client-side code.
2
+
3
+
Note that public dynamic environment variables must all be sent from the server to the client, causing larger network requests — when possible, use `$env/static/public` instead.
Copy file name to clipboardExpand all lines: packages/kit/types/ambient.d.ts
+1-48
Original file line number
Diff line number
Diff line change
@@ -10,14 +10,10 @@
10
10
* interface PageData {}
11
11
*
12
12
* interface Platform {}
13
-
*
14
-
* interface PrivateEnv {}
15
-
*
16
-
* interface PublicEnv {}
17
13
* }
18
14
* ```
19
15
*
20
-
* By populating these interfaces, you will gain type safety when using `env`, `event.locals` and `event.platform`.
16
+
* By populating these interfaces, you will gain type safety when using `event.locals`, `event.platform`, and `data` from `load` functions.
21
17
*
22
18
* Note that since it's an ambient declaration file, you have to be careful when using `import` statements. Once you add an `import`
23
19
* at the top level, the declaration file is no longer considered ambient and you lose access to these typings in other files.
@@ -60,16 +56,6 @@ declare namespace App {
60
56
* If your adapter provides [platform-specific context](https://kit.svelte.dev/docs/adapters#supported-environments-platform-specific-context) via `event.platform`, you can specify it here.
61
57
*/
62
58
exportinterfacePlatform{}
63
-
64
-
/**
65
-
* The interface that defines the dynamic environment variables exported from `$env/dynamic/private`.
* This module provides access to runtime environment variables, as defined by the platform you're running on. For example
99
-
* if you're using [`adapter-node`](https://github.com/sveltejs/kit/tree/master/packages/adapter-node) (or running
100
-
* [`vite preview`](https://kit.svelte.dev/docs/cli)), this is equivalent to `process.env`. This module only includes
101
-
* variables that _do not_ begin with [`config.kit.env.publicPrefix`](https://kit.svelte.dev/docs/configuration#kit-env-publicprefix).
102
-
*
103
-
* This module cannot be imported into client-side code.
104
-
*
105
-
* ```ts
106
-
* import { env } from '$env/dynamic/private';
107
-
* console.log(env.DEPLOYMENT_SPECIFIC_VARIABLE);
108
-
* ```
109
-
*/
110
-
declare module '$env/dynamic/private'{
111
-
exportletenv: App.PrivateEnv;
112
-
}
113
-
114
-
/**
115
-
* Similar to [`$env/dynamic/private`](https://kit.svelte.dev/docs/modules#$env-dynamic-private), but only includes
116
-
* variables that begin with [`config.kit.env.publicPrefix`](https://kit.svelte.dev/docs/configuration#kit-env-publicprefix)
117
-
* (which defaults to `PUBLIC_`), and can therefore safely be exposed to client-side code
118
-
*
119
-
* Note that public dynamic environment variables must all be sent from the server to the client, causing larger network requests — when possible, use `$env/static/public` instead.
0 commit comments