Skip to content

Commit cd85d56

Browse files
Add getLocalWorkerdCompatibilityDate documentation in the wrangler programmatic API page
1 parent 48ad4a0 commit cd85d56

File tree

1 file changed

+32
-0
lines changed
  • src/content/docs/workers/wrangler

1 file changed

+32
-0
lines changed

src/content/docs/workers/wrangler/api.mdx

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Wrangler offers APIs to programmatically interact with your Cloudflare Workers.
2323
- [`unstable_startWorker`](#unstable_startworker) - Start a server for running integration tests against your Worker.
2424
- [`unstable_dev`](#unstable_dev) - Start a server for running either end-to-end (e2e) or integration tests against your Worker.
2525
- [`getPlatformProxy`](#getplatformproxy) - Get proxies and values for emulating the Cloudflare Workers platform in a Node.js process.
26+
- [`getLocalWorkerdCompatibilityDate`](#getlocalworkerdcompatibilitydate) - Gets the latest compatibility date supported by the locally installed `workerd` package.
2627

2728
## `unstable_startWorker`
2829

@@ -455,3 +456,34 @@ The bindings supported by `getPlatformProxy` are:
455456

456457
If you are using Workers with Assets run:
457458
<PackageManagers type="exec" pkg="wrangler" args="dev -c path/to/workers-assets/wrangler.jsonc -c path/to/external-do-worker/wrangler.jsonc" />
459+
460+
## `getLocalWorkerdCompatibilityDate`
461+
462+
The `getLocalWorkerdCompatibilityDate` function returns the latest [compatibility date](/workers/configuration/compatibility-dates/) supported by the locally installed [`workerd`](https://github.com/cloudflare/workerd) package.
463+
464+
If the `workerd` package's compatibility date is in the future (which can happen on the day of a new release), today's date is returned instead to avoid potential issues.
465+
466+
### Syntax
467+
468+
```js
469+
import { getLocalWorkerdCompatibilityDate } from "wrangler";
470+
471+
const compatibilityDate = getLocalWorkerdCompatibilityDate();
472+
```
473+
474+
### Parameters
475+
476+
This function takes no parameters.
477+
478+
### Return Type
479+
480+
`getLocalWorkerdCompatibilityDate()` returns a <Type text="string" /> in `YYYY-MM-DD` format (for example, `"2025-09-27"`).
481+
482+
### Usage
483+
484+
```js
485+
import { getLocalWorkerdCompatibilityDate } from "wrangler";
486+
487+
const compatibilityDate = getLocalWorkerdCompatibilityDate();
488+
console.log(`Local workerd compatibility date: ${compatibilityDate}`);
489+
```

0 commit comments

Comments
 (0)