Setting the file. One moment.
Chapter 04 · Cloudflare Deploy
Subchapter 4.212
references/static-assets/README.mdMarkdown2 KBView on GitHub
Expert guidance for deploying and configuring static assets with Cloudflare Workers. This skill covers configuration patterns, routing architectures, asset binding usage, and best practices for SPAs, SSG sites, and full-stack applications.
// wrangler.jsonc
{
"name": "my-app",
"main": "src/index.ts",
"compatibility_date": "2025-01-01",
"assets": {
"directory": "./dist"
}
}// src/index.ts
export default {
async fetch(request: Request, env: Env): Promise<Response> {
return env.ASSETS.fetch(request);
}
};Deploy: wrangler deploy
| Factor | Workers Static Assets | Cloudflare Pages |
|---|---|---|
| Use case | Hybrid apps (static + dynamic API) | Static sites, SSG |
| Worker control | Full control over routing | Limited (Functions) |
| Configuration | Code-first, flexible | Git-based, opinionated |
| Dynamic routing | Worker-first patterns | Functions (_functions/) |
| Best for | Full-stack apps, SPAs with APIs | Jamstack, static docs |
Decision tree: