Skip to content

Commit

Permalink
update getCloudflareContext docs to reflect it being sync now
Browse files Browse the repository at this point in the history
  • Loading branch information
dario-piotrowicz committed Jan 24, 2025
1 parent 4ebec40 commit 4fbbb91
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pages/cloudflare/bindings.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { getCloudflareContext } from "@opennextjs/cloudflare";
export async function GET(request) {
let responseText = "Hello World";

const myKv = (await getCloudflareContext()).env.MY_KV_NAMESPACE;
const myKv = getCloudflareContext().env.MY_KV_NAMESPACE;
await myKv.put("foo", "bar");
const foo = await myKv.get("foo");

Expand All @@ -33,7 +33,7 @@ Add bindings to your Worker by adding them to your [wrangler configuration file]

## TypeScript type declarations for bindings

To ensure that the `env` object from `(await getCloudflareContext()).env` above has accurate TypeScript types, run the following Wrangler command to [generate types that match your Worker's configuration](https://developers.cloudflare.com/workers/languages/typescript/#generate-types-that-match-your-workers-configuration-experimental):
To ensure that the `env` object from `getCloudflareContext().env` above has accurate TypeScript types, run the following Wrangler command to [generate types that match your Worker's configuration](https://developers.cloudflare.com/workers/languages/typescript/#generate-types-that-match-your-workers-configuration-experimental):

```
npx wrangler types --experimental-include-runtime
Expand All @@ -58,7 +58,7 @@ import { getCloudflareContext } from "@opennextjs/cloudflare";


export async function GET(request) {
const { env, cf, ctx } = await getCloudflareContext();
const { env, cf, ctx } = getCloudflareContext();

// ...
}
Expand Down

0 comments on commit 4fbbb91

Please sign in to comment.