VersionMetadata
Learn how to use Cloudflare Version Metadata binding with Alchemy to access version information at runtime.
The Version Metadata binding provides access to version information about your Worker at runtime.
Minimal Example
Section titled “Minimal Example”Create a basic version metadata binding:
import { Worker, VersionMetadata } from "alchemy/cloudflare";
const worker = await Worker("versioned-worker", { name: "versioned-worker", entrypoint: "./src/worker.ts", bindings: { VERSION: VersionMetadata(), },});
Worker Runtime Usage
Section titled “Worker Runtime Usage”Access version information in your Worker:
export default { async fetch(request: Request, env: any) { const version = env.VERSION;
return new Response(JSON.stringify({ workerVersion: version.workerVersion, deploymentId: version.deploymentId, lastDeployedAt: version.lastDeployedAt, }), { headers: { "content-type": "application/json", }, }); },};
Available Properties
Section titled “Available Properties”The version metadata binding provides the following properties at runtime:
workerVersion
: The version tag of the WorkerdeploymentId
: A unique identifier for the current deploymentlastDeployedAt
: Timestamp of when the Worker was last deployed