diff --git a/content/pages/_partials/_pages_local_bindings_warning.md b/content/pages/_partials/_pages_local_bindings_warning.md new file mode 100644 index 000000000000000..4728a53b368011b --- /dev/null +++ b/content/pages/_partials/_pages_local_bindings_warning.md @@ -0,0 +1,12 @@ +--- +_build: + publishResources: false + render: never + list: never +--- + +{{}} \ No newline at end of file diff --git a/content/pages/functions/bindings.md b/content/pages/functions/bindings.md index cba2273006bd440..f2032dd6ff69239 100644 --- a/content/pages/functions/bindings.md +++ b/content/pages/functions/bindings.md @@ -55,6 +55,10 @@ export const onRequest: PagesFunction = async (context) => { While developing locally, interact with your KV namespace by adding `-k ` or `--kv=` to your run command. For example, if your namespace is bound to `TODO_LIST`, access the KV namespace in your local dev by running `npx wrangler pages dev --kv=TODO_LIST`. The data from this namespace can be accessed using `context.env.TODO_LIST`. +Alternatively, you can interact with a KV namespace locally via a `wrangler.toml` file. Refer to [Wrangler configuration](/workers/wrangler/configuration/#kv-namespaces) for more information. + +{{}} + ## Durable Object namespaces [Durable Objects](/durable-objects/) (DO) are Cloudflare's strongly consistent data store that power capabilities such as connecting WebSockets and handling state. To bind your DO namespace to your Pages Function: @@ -147,7 +151,17 @@ export const onRequest: PagesFunction = async (context) => { ### Interact with your R2 buckets locally -While developing locally, interact with an R2 bucket by adding `--r2=` to your run command. For example, if your bucket is bound to `BUCKET`, access this bucket in local dev by running `npx wrangler pages dev --r2=BUCKET`. Interact with this binding by using `context.env` (for example, `context.env.BUCKET`). +While developing locally, interact with an R2 bucket by adding `--r2=` to your run command. + +{{}} + +If your bucket is bound to `BUCKET`, access this bucket in local dev by running `npx wrangler pages dev --r2=BUCKET`. Interact with this binding by using `context.env` (for example, `context.env.BUCKET`). + +Alternatively, you can interact with an R2 bucket locally via a `wrangler.toml` file. Refer to [Wrangler configuration](/workers/wrangler/configuration/#r2-buckets) for more information. + +{{}} ## D1 databases @@ -207,6 +221,10 @@ Specifically: Refer to the [D1 client API documentation](/d1/how-to/query-databases/) for the API methods available on your D1 binding. +Alternatively, you can interact with a D1 database locally via a `wrangler.toml` file. Refer to [Wrangler configuration](/workers/wrangler/configuration/#d1-databases) for more information. + +{{}} + ## Workers AI [Workers AI](/workers-ai/) allows you to run powerful AI models. To bind Workers AI to your Pages Function: @@ -306,6 +324,10 @@ export const onRequest: PagesFunction = async (context) => { To interact with a [service binding](/workers/configuration/bindings/about-service-bindings/) while developing locally, run the Worker you want to bind to via `wrangler dev` and in parallel, run `wrangler pages dev` with `--service =` where `SCRIPT_NAME` indicates the name of the Worker. For example, if your Worker is called `my-worker`, connect with this Worker by running it via `npx wrangler dev` (in the Worker's directory) alongside `npx wrangler pages dev --service MY_SERVICE=my-worker` (in the Pages' directory). Interact with this binding by using `context.env` (for example, `context.env.MY_SERVICE`). +Alternatively, you can interact with a service binding locally via a `wrangler.toml` file. Refer to [Wrangler configuration](/workers/wrangler/configuration/#service-bindings) for more information. + +{{}} + ## Queue Producers [Queue Producers](/queues/reference/javascript-apis/#producer) enable you to send messages into a Queue within your Pages Function. To add a Queue producer binding to your Pages Function: