LLevelUp
0
← Back to topic

Workers Basics

Cloudflare Workers run JavaScript or TypeScript at the edge. A Worker receives a Request and returns a Response using web-standard APIs.

export default {
  async fetch(request: Request): Promise<Response> {
    const url = new URL(request.url);
    if (url.pathname === "/health") return Response.json({ ok: true });
    return new Response("Not found", { status: 404 });
  },
};

Workers are strong for lightweight APIs, redirects, request rewriting, auth gates, and edge personalization.

WARNING

Workers are not a normal long-running Node server. Check runtime APIs and limits before moving backend code directly.

Further Learning

  • “Cloudflare Workers fetch handler” — request/response basics
  • “Cloudflare Workers limits” — CPU, memory, and runtime behavior
  • “Wrangler Cloudflare Workers” — local dev and deploy CLI