Cloudflare Workers Explained: What They Are and What to Build
If you've ever wanted a piece of code to run instantly, anywhere in the world, without spinning up a server — that's the problem Cloudflare Workers solves. For small businesses and founders, this isn't just a developer toy. It's a way to add real functionality to your site (forms, redirects, APIs, A/B tests) without paying for a backend you don't need.
Let's break down what a Worker actually is, how it differs from a traditional server, and the kinds of things you can ship with one this week.
What is a Cloudflare Worker?
A Cloudflare Worker is a small piece of JavaScript (or TypeScript, Rust, or Python) that runs on Cloudflare's global network of 300+ data centers. When a request hits one of those locations, your code executes there — typically within 5 milliseconds — and sends a response back to the user.
Think of it as a function that lives on the edge of the internet, between your visitor and your website. It can:
- Intercept and modify incoming requests
- Return a response without ever touching your origin server
- Call other APIs, databases, or services
- Cache results, rewrite HTML, or run logic before content is delivered
How it differs from traditional hosting
A normal server (or even a typical serverless function on AWS Lambda) runs in one region. A user in Sydney hitting a server in Virginia waits 200+ms just for the network round trip. Workers run in the data center closest to the user — Sydney, Tokyo, London, wherever — so the response feels instant.
The other big difference: Workers use the V8 isolate model instead of containers. That means no cold starts. Your code is ready to run within a millisecond of a request arriving.
Pricing and limits worth knowing
Workers are cheap, which is part of why they're popular with founders bootstrapping a product:
- Free plan: 100,000 requests per day, 10ms CPU time per request
- Paid plan: $5/month for 10 million requests, then $0.30 per million
- CPU limit: Up to 30 seconds on the paid plan (more than enough for most tasks)
For comparison, a basic VPS to run an equivalent backend would start around $5–$10/month and require you to manage updates, scaling, and security yourself.
What you can actually build with Cloudflare Workers
Here's where it gets practical. These are real projects you can ship — most of them in under a day.
1. Smart redirects and URL rewrites
If you've ever migrated a site and needed hundreds of 301 redirects, a Worker handles this without touching your hosting config. Example:
export default {
async fetch(request) {
const url = new URL(request.url);
if (url.pathname === '/old-pricing') {
return Response.redirect('https://example.com/pricing', 301);
}
return fetch(request);
}
};You can also do geo-based redirects (send UK visitors to /uk, US visitors to /us) using the request.cf.country property Cloudflare attaches to every request.
2. A lightweight API for your site
Need a contact form, newsletter signup, or feedback widget that posts data somewhere? Instead of building a backend, write a Worker that:
- Accepts the POST request from your form
- Validates the input
- Forwards it to an email service (Resend, Postmark) or a database (Cloudflare D1, Airtable, Notion)
- Returns a success message
That's typically 30–50 lines of code, and you'll never pay for it on the free tier unless you're getting thousands of submissions daily.
3. A/B testing without third-party scripts
Heavy A/B testing tools slow your site down. A Worker can split traffic by rewriting HTML at the edge — variant B is served only to a percentage of users, no client-side flicker, no Lighthouse penalty. You set a cookie to keep users in the same variant on return visits.
4. Authentication and access control
Workers can sit in front of any URL and check for a valid session, JWT, or API key before passing the request through. This is useful for:
- Locking down staging environments with a simple password
- Protecting premium content behind a paywall
- Adding basic auth to admin tools that don't have their own login
5. Image transformation and optimization
Pair Workers with Cloudflare Images or R2 storage and you can resize, crop, and reformat images on the fly. Upload one high-res photo, serve a perfectly sized WebP to every device. No build step, no media plugin.
6. AI-powered features
Cloudflare Workers AI lets you call open-source models (Llama, Mistral, Whisper, Stable Diffusion) directly from a Worker. Practical builds:
- Auto-generate product descriptions from a title
- Translate page content based on visitor location
- Summarize long blog posts into meta descriptions
- Build a basic chatbot for customer questions
7. Webhooks and integrations
If you use Stripe, Shopify, or any service that sends webhooks, a Worker is the perfect listener. It receives the event, processes it, and triggers actions — send a Slack notification on a new sale, sync a customer to your CRM, or update a Google Sheet.
8. Edge caching for slow APIs
If your site depends on a third-party API that's slow or rate-limited, a Worker can cache the response for a few minutes at the edge. Your first visitor pays the cost; the next 10,000 get an instant response.
How to deploy your first Worker
You can get a Worker live in about 10 minutes:
- Sign up at workers.cloudflare.com (free)
- Install Wrangler, Cloudflare's CLI:
npm install -g wrangler - Run
wrangler init my-workerto scaffold a project - Edit
src/index.jswith your logic - Run
wrangler deploy— your Worker is now live on a*.workers.devsubdomain
To use your own domain, add the route in your Cloudflare dashboard under Workers Routes (your domain must already use Cloudflare DNS).
When a Worker is the wrong choice
Workers aren't a silver bullet. Skip them if:
- You need long-running processes (video encoding, large file processing)
- You're doing heavy CPU work beyond 30 seconds per request
- Your team doesn't have JavaScript familiarity and you'd be better off with a managed backend like Supabase or Firebase
- You need persistent WebSocket connections at scale (possible with Durable Objects, but more complex)
For most small business sites — marketing pages, lead capture, product catalogs, light dashboards — Workers cover 90% of what a custom backend would do, at a fraction of the cost and complexity.
Want this built for you?
At Axoxweb, we build fast, modern websites and web apps for small businesses and founders — including edge-powered features like custom APIs, smart redirects, and AI integrations on Cloudflare Workers. If you'd rather ship than learn Wrangler, get in touch at axoxweb.com.