Cloudflare Assets
Rules
- Configure static assets in
wrangler.jsoncwith anassetsblock that sets bothbindinganddirectory. - Serve static files from the Worker by returning
env.ASSETS.fetch(request)insidefetch. - Keep the binding name consistent across config and code (for example
ASSETSin both places).
Example 1: wrangler.jsonc
{
"$schema": "node_modules/wrangler/config-schema.json",
"name": "my-worker",
"main": "src/index.ts",
"compatibility_date": "2026-02-24",
"assets": {
"binding": "ASSETS",
"directory": "./public"
}
}Example 2: Minimal Worker
export default {
async fetch(request, env, ctx) {
return env.ASSETS.fetch(request);
},
};