Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 18 additions & 27 deletions docs/2.deploy/20.providers/cloudflare.md
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ defineHandler(async (event) => {

### Access to the bindings in local dev

To access bindings in dev mode, we first define them. You can do this in a `wrangler.toml`/`wrangler.json` file, or directly in your Nitro config under `cloudflare.wrangler` (accepts the same type as `wrangler.json`).
To access bindings in dev mode, we first define them. You can do this in a `wrangler.jsonc`/`wrangler.json`/`wrangler.toml` file

For example, to define a variable and a KV namespace in `wrangler.toml`:

Expand Down Expand Up @@ -311,32 +311,6 @@ id = "xxx"

::

Or in your Nitro config:


```js [nitro.config.js]
import { defineNitroConfig } from "nitro/config";

export default defineNitroConfig({
cloudflare: {
wrangler: {
Comment thread
pi0 marked this conversation as resolved.
vars: {
MY_VARIABLE: "my-value"
},
kv_namespaces: [
{
binding: "MY_KV",
id: "xxx"
}
]
}
}
});
```

> [!NOTE]
> Only bindings in the default environment are recognized.

Next we install the required `wrangler` package (if not already installed):

:pm-install{name="wrangler -D"}
Expand All @@ -346,3 +320,20 @@ From this moment, when running
:pm-run{script="dev"}

you will be able to access the `MY_VARIABLE` and `MY_KV` from the request event just as illustrated above.

#### Wrangler environments

If you have multiple Wrangler environments, you can specify which Wrangler environment to use during Cloudflare dev emulation:

```ts [nitro.config.ts]
import { defineNitroConfig } from "nitro/config";

export default defineNitroConfig({
preset: 'cloudflare-module',
cloudflare: {
dev: {
environment: 'preview'
}
}
})
```
Loading