Skip to Content
getting-startedCloudflare Workers

Last Updated: 3/7/2026


Cloudflare Workers

Cloudflare Workers  is a JavaScript edge runtime on Cloudflare CDN.

You can develop the application locally and publish it with a few commands using Wrangler . Wrangler includes trans compiler, so we can write the code with TypeScript.

1. Setup

A starter for Cloudflare Workers is available. Start your project with “create-hono” command. Select cloudflare-workers template for this example.

npm create hono@latest my-app

Move to my-app and install the dependencies.

cd my-app npm i

2. Hello World

Edit src/index.ts like below.

import { Hono } from 'hono' const app = new Hono() app.get('/', (c) => c.text('Hello Cloudflare Workers!')) export default app

3. Run

Run the development server locally. Then, access http://localhost:8787 in your web browser.

npm run dev

4. Deploy

If you have a Cloudflare account, you can deploy to Cloudflare.

npm run deploy

Bindings

In Cloudflare Workers, we can bind environment values, KV namespace, R2 bucket, or Durable Object. You can access them in c.env.

type Bindings = { MY_BUCKET: R2Bucket USERNAME: string PASSWORD: string } const app = new Hono<{ Bindings: Bindings }>() app.put('/upload/:key', async (c, next) => { const key = c.req.param('key') await c.env.MY_BUCKET.put(key, c.req.body) return c.text(`Put ${key} successfully!`) })

Serve static files

You can use the Static Assets feature of Cloudflare Workers. Specify the directory in wrangler.toml:

assets = { directory = "public" }