Skip to content

Commit 5ff4f91

Browse files
RomanistHereghostdevvbenmccann
authored
docs: clarify cloudflare env usage (#10096)
Co-authored-by: Willow (GHOST) <[email protected]> Co-authored-by: Ben McCann <[email protected]>
1 parent 18b0599 commit 5ff4f91

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

documentation/docs/25-build-and-deploy/60-adapter-cloudflare.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ When configuring your project settings, you must use the following settings:
6363

6464
> You need to add a `NODE_VERSION` environment variable to both the "production" and "preview" environments. You can add this during project setup or later in the Pages project settings. SvelteKit requires Node `16.14` or later, so you should use `16` as the `NODE_VERSION` value.
6565
66-
## Environment variables
66+
## Bindings
6767

68-
The [`env`](https://developers.cloudflare.com/workers/runtime-apis/fetch-event#parameters) object, containing KV/DO namespaces etc, is passed to SvelteKit via the `platform` property along with `context` and `caches`, meaning you can access it in hooks and endpoints:
68+
The [`env`](https://developers.cloudflare.com/workers/runtime-apis/fetch-event#parameters) object contains your project's [bindings](https://developers.cloudflare.com/workers/platform/environment-variables/), which consist of KV/DO namespaces, etc. It is passed to SvelteKit via the `platform` property, along with `context` and `caches`, meaning that you can access it in hooks and endpoints:
6969

7070
```js
7171
// @errors: 7031
@@ -74,6 +74,8 @@ export async function POST({ request, platform }) {
7474
}
7575
```
7676

77+
> SvelteKit's built-in `$env` module should be preferred for environment variables.
78+
7779
To make these types available to your app, reference them in your `src/app.d.ts`:
7880

7981
```diff
@@ -92,7 +94,7 @@ declare global {
9294
export {};
9395
```
9496

95-
> `platform.env` is only available in the production build. Use [wrangler](https://developers.cloudflare.com/workers/cli-wrangler) to test it locally
97+
> `platform.env` is only available in the production build. Use [wrangler](https://developers.cloudflare.com/workers/cli-wrangler) to test it locally.
9698
9799
## Notes
98100

0 commit comments

Comments
 (0)