Languages
Background
Workers is a polyglot platform. You can write Workers in JavaScript, TypeScript, or any programming language that compiles to WebAssembly .
JavaScript / TypeScript
The Workers platform fully supports JavaScript standards, as defined by
TC39
(ECMAScript). Cloudflare recommends writing Workers using JavaScript or TypeScript, and publishes type definitions to
GitHub
and
npm
(
npm install -D @cloudflare/workers-types
).
| Language | Template |
|---|---|
| JavaScript | cloudflare/workers-sdk/templates/worker |
| TypeScript | cloudflare/workers-sdk/templates/worker-typescript |
Resources
- Quickstarts – More example repos to use as a basis for your projects
- TypeScript type definitions
- JavaScript and web standard APIs
- Tutorials
WebAssembly (Wasm)
WebAssembly (abbreviated as “Wasm”) is a binary format that many languages can be compiled to. This allows you to write Workers using programming language beyond JavaScript, such as Rust, C, C++, Go and more.
Resources on WebAssembly
Compile languages to JavaScript
You can write Workers with any language that can compile to JavaScript, including the languages below.
| Language | Example project |
|---|---|
| Kotlin | cloudflare/kotlin-worker-hello-world |
| Dart | cloudflare/dart-worker-hello-world |
| Python | cloudflare/python-worker-hello-world |
| Scala | cloudflare/scala-worker-hello-world |
| Reason/OCaml | cloudflare/reason-worker-hello-world |
| Perl | cloudflare/perl-worker-hello-world |
| PHP | cloudflare/php-worker-hello-world |
| FSharp | fable-compiler/cfworker-hello-world |
Refer to the Cloudflare Workers announces broad language support blog post for more information.