Skip to content
Merged
Changes from 1 commit
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
12 changes: 12 additions & 0 deletions pages/cloudflare/bindings.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@ export async function GET(request) {
}
```

<Callout type='info'>
`getCloudflareContext` can only be used in SSG routes in "async mode" (where the function's returned value is wrapped
in a promise), to run the function in such a way simply provide an options argument with the `async` flag set to `true`:
```js
const context = await getCloudflareContext({ async: true });
```

**WARNING**: During SSG caution is advised since secrets (stored in `.dev.vars` files) and local development
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

We should really have an HowTo to explain the setup...

values from bindings (like values saved in a local KV) will be used for the pages static generation.

</Callout>

#### How to add bindings to your Worker

Add bindings to your Worker by adding them to your [wrangler configuration file](https://developers.cloudflare.com/workers/wrangler/configuration/).
Expand Down