Skip to main contentSkip to footer

How to Host a Free 'Coming Soon' Page with Cloudflare Workers: Step-by-Step Guide

Posted 9 months ago · 6 min read

Follow this step-by-step guide on setting up a free coming soon page using Cloudflare workers—no hosting needed!

Stacey has shoulder-length wavy hair and is smiling at the camera. She is wearing a dark scarf and a purple top. The background is a lime green circle.

Stacey Watson

A person uses a laptop displaying a "Coming Soon" screen with a rocket icon and a "GO" button

TL;DR: Take me to the steps.

Alright, picture this: you’ve got this brilliant idea swirling in your head, you’re pumped up and ready to go. You even went ahead and snagged the perfect domain name. Now, you’re just a few clicks away from entering your credit card details and paying for website hosting.

But hold up, there’s a tiny voice in your head whispering doubts. Will this be another one of those “Coming Soon” pages that just gathers dust for years without any action from you? Trust me, I’ve been there… many a times.

Or maybe, you’re brimming with ideas and have all the time in the world to dedicate to your project. But let’s face it, building a website takes time. In the meantime, you’ll want to start collecting email addresses and start sharing your exciting venture with everyone you know.

That’s where a “Coming Soon” page becomes your secret weapon. It’s a crucial step in launching a new website or service. It lets your audience know that something awesome is brewing, even if it’s still simmering behind the scenes.

But here’s the annoying part – you have to pay for hosting that page every month. Ugh, right?

Well, guess what? I’ve got a little secret for you. There’s actually a free way to host your “Coming Soon” page using Cloudflare. Yes, you heard me right!

By harnessing the power of Cloudflare Workers, you can host your page for absolutely free with minimal setup. And if you keep reading, I’m going to teach you how.

Just So You Know

There are account plan limits for Cloudflare Workers. Learn more about Cloudflare Workers limits on Cloudflare Docs.

What are Cloudflare Workers?

Cloudflare Workers are a serverless platform that allows developers to deploy and run their code globally. This means your code can be executed closer to users, improving performance and reducing latency. And it’s a really good use case for serving static pages, such as coming soon pages that have minimal overhead.

And it’s pretty easy to set up!

Here’s a step-by-step guide on how to make it happen.

But before we dive in, let’s assume you’ve already signed up for a free Cloudflare account and your nameservers are pointed to Cloudflare.

Here’s the step-by-step guide:

Step 1: Access Your Account

Login to Cloudflare.

If you have multiple accounts, select the correct account to access.

If you only have one account, skip this step.

Screenshot of a web page titled "Accounts" featuring a search bar and a list of blurred email addresses followed by "Account." A cursor is hovering "Name@yourdomain.com's Account" indicating a click.

Step 2: Click on the Domain You Wish To Setup the Holding Page For

Screenshot of the Cloudflare Account Home, with an arrowing pointing to a domain, indicating to click the domain

Step 3: Navigate to “Workers Routes” (formerly Workers & Pages)

Screenshot of the Overview page in Cloudflare, with an arrow pointing to the "Workers Routes" menu item located in the left menu

Step 4: Click the “Manage Workers” Button

Screenshot of the "Workers Routes" page in Cloudflare, with an arrow pointing to the "Manage Workers" button

Step 5: Click “Get started” next to “Start with Hello World!” in the “Workers” tab

If you already have existing workers or pages, you’ll need to first click the blue “Create” button to see this screen.

Screenshot of the Cloudflare interface, showing an arrow pointed to "Get started" next to "Start with Hello World!"

Step 6: Name Your Worker Script

In the “Worker name” text field, label your worker script.

For example: coming-soon-page.

Don’t worry about the Code preview. We’ll modify this shortly.

Click the “Deploy” button.

A screenshot of the Cloudflare interface for deploying a "Hello World" script. The page shows fields for naming the worker and a code preview box containing JavaScript code. A "Create" button is at the bottom-right corner.

Step 7: Click the “Edit Code” Button

Cloudflare page showing a global map with blue dots indicating server locations. Text reads, "Congratulations! Your Worker is deployed to Region: Earth." Options to configure or edit the worker are available. A cursor is clicking the "Edit code" button.

Step 8: Copy and Paste Worker Code to worker.js

Replace the default code in the Cloudflare Workers editor (worker.js) with the code below.

Screenshot of a Cloudflare dashboard. On the left is a serverless function code editor with basic JavaScript code, and on the right is a request panel showing a GET method with various HTTP headers and a response preview.

Below is the code to copy and paste in the worker.js.

addEventListener('fetch', event => {
  event.respondWith(handleRequest(event.request))
})

async function handleRequest(request) {
  const html = `
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Coming Soon</title>
        <style>
            body {
                display: flex;
                justify-content: center;
                align-items: center;
                text-align: center;
                height: 100vh;
                margin: 0;
                font-family: Helvetica, sans-serif;
                background-color: #f3f3f3;
                color: #333;
            }
            h1 {
                font-size: 4em;
                margin-bottom: 0.5em;
            }
            p {
                font-size: 1.5em;
            }
        </style>
    </head>
    <body>
        <div class="wrapper">
            <div class="icon">
                <svg xmlns="http://www.w3.org/2000/svg" width="200" height="200" viewBox="0 0 24 24">
                    <path fill="currentColor" d="M5.52 20.596V15.46q0-.404.189-.768q.19-.363.537-.58l1.196-.783q.175 1.754.454 3.036q.279 1.283.906 2.91l-3.283 1.321Zm4.051-1.788q-.606-1.535-.934-3.145q-.33-1.61-.33-3.276q0-2.645.902-4.86q.9-2.214 2.791-3.927q1.89 1.713 2.791 3.928q.901 2.214.901 4.859q0 1.661-.329 3.268q-.328 1.607-.934 3.153H9.57ZM12 12.5q.633 0 1.066-.434q.434-.433.434-1.066t-.434-1.066Q12.633 9.5 12 9.5t-1.066.434Q10.5 10.367 10.5 11t.434 1.066q.433.434 1.066.434Zm6.462 8.096l-3.283-1.302q.627-1.627.906-2.919q.278-1.292.453-3.046l1.197.802q.348.217.537.58q.19.364.19.768v5.117Z"/>
                </svg>
            </div>
            <h1>Coming Soon</h1>
            <p>Get ready for something exciting!</p>
        </div>
    </body>
    </html>
  `;

  return new Response(html, {
    headers: { 'content-type': 'text/html' },
  })
}

This is just a simple coming soon page to show you what can be done, but go ahead and get creative and build what you want to your liking.

In the preview tab, click the refresh icon next to the domain to see the changes.

Hot Tip

If you want to replace the rocket icon, simply replace the SVG code (lines 37-39) in the above worker.js. The existing rocket icon is from Google’s Material Symbols & Icons.

Step 9: Click the “Deploy” Button

Screenshot of the Cloudflare worker.js interface, with an arrow pointing to the "Deploy" button

Step 10: Go Back to “Workers & Pages”

Go back by clicking “<- coming-soon-page” link above the worker.js, and then clicking “Account Home” from the left menu panel.

A Cloudflare Workers interface showing the code for a custom “Coming Soon” page on the left and the live preview with a rocket icon and “Coming Soon” message on the right.

Step 11: Click on Your Domain Again

Cloudflare dashboard showing the Websites section, with one domain, yourdomain.com, listed and options to add a site or filter domains.

Step 12: Click on “Workers Routes”

Cloudflare dashboard overview showing analytics for unique visitors, requests, cache rates, data served, and cached data over time with DNS and quick action options on the right.

Step 13: Click on the “Add route” button

Cloudflare dashboard showing the Workers Routes section, with options to add HTTP routes and manage Workers KV, and no routes currently configured.

Step 14: Route Traffic Through Your Worker

Enter the following in the “Route” text field.

yourdomain.com/*

Make sure to replace “yourdomain.com” with your actual domain. Add another one with:

www.yourdomain.com/*

Then, select the Worker you created earlier, ‘coming-soon-page’, and click “Save”

A modal in the Cloudflare Workers dashboard showing the “Add route” form, where a route pattern and Worker can be selected before saving.

Step 15: Navigate to the “DNS” Page

Screenshot of the "Workers Routes" page in Cloudflare, with an arrow pointing to the "DNS" menu item in the left navigation panel

Step 16: Update Your “A” Record for Your Domain, and the “CNAME” for “www”

These next changes will make your coming soon page live. Only make these changes when you’re ready!

Set the “A” record for your domain to: 192.0.2.1.

Set your “CNAME” record for “www” to: “yourdomain.com” (replace this with your domain)

Ensure both of these records are proxied. The cloud icon should be orange, not grey.

Note: Once you make these changes, your coming soon page will be live!

Cloudflare DNS records page showing an A record for "yourdomain.com" with IP address "192.0.2.1" and a CNAME for "www" pointing to "yourdomain.com".

Step 17: Test Your Worker

Open this URL in your browser to see your “Coming Soon” page in action.

A browser mockup displaying a centered “Coming Soon” message with a rocket icon and a short tagline.

If you get a Cloudflare error, follow these steps:

  1. Navigate back to “Workers Routes”
  2. Click on your worker (eg. coming-soon-page)
  3. Under “Domains & Routes”, disable the worker for ALL Routes except for *.yourdomain.com/*

That’s All Folks!

Hosting a “Coming Soon” page using Cloudflare Workers is a straightforward process that leverages serverless technology for high performance and scalability. Plus, it’s free! By following the steps outlined above, you can quickly get a placeholder page up and running while you work on your full site.

You can also create a Worker for a maintenance page. This is a good way to inform your users that your website is undergoing maintenance.

Your “Coming Soon” Page Is Live! Now What?

Let’s make sure what comes next is worth the wait. CodeInk helps creators and small businesses move from placeholder to powerhouse with strategy-driven web design that actually performs.