AccountId
The AccountId resource retrieves a Cloudflare Account ID for use with other Cloudflare resources.
Minimal Example
Section titled “Minimal Example”Get the account ID from environment variables or API token:
import { AccountId } from "alchemy/cloudflare";
const accountId = await AccountId("my-account");
With Explicit API Key
Section titled “With Explicit API Key”Provide an API key and email directly:
import { AccountId } from "alchemy/cloudflare";
const accountId = await AccountId("my-account", { apiKey: alchemy.secret(process.env.CF_API_KEY), email: "user@example.com",});
Bind to a Worker
Section titled “Bind to a Worker”Use the account ID with a Worker:
import { Worker, AccountId } from "alchemy/cloudflare";
const accountId = await AccountId("my-account");
await Worker("my-worker", { name: "my-worker", script: "console.log('Hello, world!')", accountId: accountId,});