Deploying Your First Worker
Learn the steps to deploy your Worker to Cloudflare's edge network and test its live functionality.
Deploying Your First Worker is a free Edge Computing with Cloudflare Workers & Deno lesson on CoddyKit — lesson 3 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Edge Computing with Cloudflare Workers & Deno learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Ready to Go Live!
You've learned to set up your environment and write a basic Cloudflare Worker. Now, let's make it accessible to the world!
Deploying your Worker means pushing your code to Cloudflare's global network, making it run at the 'edge' – closer to your users.
Before You Publish
Before deploying, ensure you've completed a couple of essential steps:
- Cloudflare Account: You need an active Cloudflare account.
- Wrangler Login: You must be logged in to Wrangler CLI. If not, run
wrangler loginto authenticate with your Cloudflare account.
These prerequisites ensure Wrangler has permission to deploy to your account.
The `wrangler publish` Command
The core command for deploying your Cloudflare Worker is wrangler publish.
You run this command from within your Worker project directory. It handles everything from bundling your code to updating it on Cloudflare's edge network.
What `publish` Does
When you run wrangler publish, several things happen:
- Bundling: Your Worker code (often JavaScript or TypeScript) is processed and optimized.
- Uploading: The bundled code is securely uploaded to Cloudflare's global network.
- Deployment: Cloudflare then makes your Worker live, routing requests to it from the edge closest to the user.
This process is usually very fast!
Our Example Worker
Let's use a simple 'Hello from the Edge!' Worker for deployment. This Worker responds to any incoming request with a plain text message.
Try running this example locally first, then we'll deploy it.
export default {
async fetch(request) {
return new Response("Hello from the Edge!", {
headers: { 'content-type': 'text/plain' },
});
},
};Deploying Your Worker
Assuming you have the example Worker code in a project folder (e.g., my-first-worker) and have run wrangler login, navigate to that directory in your terminal.
Then, simply execute the publish command:
cd my-first-worker
wrangler publishDeployment Confirmation
After running wrangler publish, you'll see output in your terminal indicating success. It will also provide the public URL where your Worker is now live.
This URL typically looks like https://your-worker-name.your-username.workers.dev.
Testing Your Live Worker
Now that your Worker is deployed, let's test it! You can use your web browser or a command-line tool like curl.
Open your browser and navigate to the URL provided by wrangler publish. You should see 'Hello from the Edge!'.
curl https://your-worker-name.your-username.workers.devUpdating Your Worker
The beauty of Workers is how easy it is to update them. If you make changes to your Worker's code, simply save your changes and run wrangler publish again.
Cloudflare will automatically update your live Worker with the new code, often within seconds!
Deployment Process Check
You've just deployed your first Worker! Let's quickly review the steps involved.
Recap: Your Worker is Live!
Congratulations! You've successfully deployed your first Cloudflare Worker to the edge network.
- You used
wrangler publishto deploy your code. - You verified its live functionality via its public URL.
- You learned that updates are as simple as running
publishagain.
Your code is now running globally, closer to users than ever before!
Frequently asked questions
Is the “Deploying Your First Worker” lesson free?
Yes — the full text of “Deploying Your First Worker” is free to read here on the web, and the Edge Computing with Cloudflare Workers & Deno course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Edge Computing with Cloudflare Workers & Deno course, upgrade to CoddyKit PRO.
What will I learn in “Deploying Your First Worker”?
Learn the steps to deploy your Worker to Cloudflare's edge network and test its live functionality. You practise Edge Computing with Cloudflare Workers & Deno with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Edge Computing with Cloudflare Workers & Deno?
No prior experience is required. Edge Computing with Cloudflare Workers & Deno on CoddyKit is structured for beginners through advanced learners; this is — lesson 3 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Deploying Your First Worker” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Edge Computing with Cloudflare Workers & Deno lesson?
Yes. Every Edge Computing with Cloudflare Workers & Deno lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Setting Up Worker Environment
- Handling HTTP Requests
- Deploying Your First Worker
- Environment Variables & Secrets in Workers