# @cloudflare/workers-types

> TypeScript typings for Cloudflare Workers

Latest version **5.20260921.1** (published 2026-09-21) · MIT OR Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @cloudflare/workers-types
pnpm add @cloudflare/workers-types
yarn add @cloudflare/workers-types
bun add @cloudflare/workers-types
```

## Health

**Score 65/100 (B)** — status: active.

Positive: has types; no vulnerabilities; has provenance; recently updated; high maintenance score.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 5.20260921.1 |
| Published | 2026-09-21 |
| First published | 2019-06-13 |
| Weekly downloads | 0 |
| License | MIT OR Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 2.3 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 8723 |
| Author | Cloudflare Workers DevProd Team |
| Maintainers | cf-ci-write, dash_service_account, wrangler-publisher, cf-npm-publish |

## Links

- npm: https://www.npmjs.com/package/@cloudflare/workers-types
- Repository: https://github.com/cloudflare/workerd
- Homepage: https://github.com/cloudflare/workerd#readme
- Issues: https://github.com/cloudflare/workerd/issues
- npm.io page: https://npm.io/package/@cloudflare/workers-types

## Recent versions

- 5.20260921.1 (latest) — 2026-09-21
- 0.20250124.2 (beta) — 2025-01-24
- 0.20240712.0 (alpha) — 2024-07-16
- 5.20260920.1 — 2026-09-20
- 5.20260919.1 — 2026-09-19
- 5.20260918.1 — 2026-09-18
- 5.20260917.1 — 2026-09-17
- 5.20260916.1 — 2026-09-16
- 5.20260915.1 — 2026-09-15
- 5.20260914.1 — 2026-09-14
- 5.20260911.1 — 2026-09-11
- 5.20260910.1 — 2026-09-10
- 5.20260908.1 — 2026-09-08
- 5.20260907.1 — 2026-09-07
- 5.20260906.1 — 2026-09-06
- … 516 more at https://npm.io/package/@cloudflare/workers-types/versions

## README

# Cloudflare Workers Types

> **Note**
>
> We now recommend using the [Wrangler CLI](https://www.npmjs.com/package/wrangler) and the `wrangler types` command to generate types based on your compatibility date _and_ compatibility flags. You can learn more about this, and how to migrate from @cloudflare/workers-types [here in our docs](https://developers.cloudflare.com/workers/languages/typescript/#generate-types).
>
> @cloudflare/workers-types will continue to be published on the same schedule.


## Install

```bash
npm install -D @cloudflare/workers-types
-- Or
yarn add -D @cloudflare/workers-types
```

## Usage

The following is a minimal `tsconfig.json` for use alongside this package:

**`tsconfig.json`**

```json
{
  "compilerOptions": {
    "target": "esnext",
    "module": "esnext",
    "lib": ["esnext"],
    "types": ["@cloudflare/workers-types"]
  }
}
```

### Compatibility dates

The Cloudflare Workers runtime manages backwards compatibility through the use of [Compatibility Dates](https://developers.cloudflare.com/workers/platform/compatibility-dates/). The `@cloudflare/workers-types` package provides a typing environment that corresponds to the latest version of the Cloudflare Workers runtime. The `@cloudflare/workers-types/experimental` entrypoint is also available for APIs guarded by experimental compatibility flags. Instead of using `@cloudflare/workers-types` directly, we recommend following the [Typescript language documentation](https://developers.cloudflare.com/workers/languages/typescript/) for Cloudflare Workers to generate a runtime typing environment that corresponds exactly to your compatibility date and flags.

### Importable Types

It's not always possible (or desirable) to modify the `tsconfig.json` settings for a project to include all the Cloudflare Workers types. For use cases like that, this package provides importable versions of its types, which are usable with no additional `tsconfig.json` setup. For example:

```ts
import type { Request as WorkerRequest, ExecutionContext } from "@cloudflare/workers-types"

export default {
  fetch(request: WorkerRequest, env: unknown, ctx: ExecutionContext) {
    return new Response("OK")
  }
}
```


### Using bindings

It's recommended that you create a type file for any bindings your Worker uses. Create a file named
`worker-configuration.d.ts` in your src directory.

If you're using Module Workers, it should look like this:
```typescript
// worker-configuration.d.ts
interface Env {
  MY_ENV_VAR: string;
  MY_SECRET: string;
  myKVNamespace: KVNamespace;
}
```
For Service Workers, it should augment the global scope:
```typescript
// worker-configuration.d.ts
declare global {
  const MY_ENV_VAR: string;
  const MY_SECRET: string;
  const myKVNamespace: KVNamespace;
}
export {}
```

Wrangler can also generate this for you automatically from your `wrangler.toml` configuration file, using the `wrangler types` command.

---
_Source: https://npm.io/package/@cloudflare/workers-types · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
