Skip to content
GitHubXDiscord

VersionMetadata

The Version Metadata binding provides access to version information about your Worker at runtime.

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(),
},
});

Access version information in your Worker:

src/worker.ts
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",
},
});
},
};

The version metadata binding provides the following properties at runtime:

  • workerVersion: The version tag of the Worker
  • deploymentId: A unique identifier for the current deployment
  • lastDeployedAt: Timestamp of when the Worker was last deployed