How to self-host a CMS on Cloudflare Workers, D1 and R2 (no servers, no Docker)
By the SharpWrite team · Published · Updated
Short answer
You can self-host a CMS on Cloudflare with no servers and no Docker. A Worker runs the site and admin, D1 holds the content and R2 holds the images. With SharpWrite Self-host it takes about 15 minutes and one setup command, and you need Node.js 22, a Cloudflare account with R2 switched on, and an email-sending key.
In this post
Self-hosting used to mean renting a server, installing a database, setting up backups and patching it forever. On Cloudflare you skip most of that. You deploy code to Workers, store data in D1 and files in R2, and Cloudflare runs the machines.
This guide walks through the whole thing using SharpWrite Self-host as the example, and is honest about where it can go wrong.
Why Cloudflare for a CMS
A CMS is mostly reads: your site asks for published content again and again, and now and then you edit something. That pattern suits the edge:
- Workers run your code close to the visitor, with no server to manage.
- D1 is a SQLite database managed by Cloudflare. Content, users and API keys live here.
- R2 stores images and files, with no charge for data leaving it to the internet.
For a one-person site, that adds up to a small, fast setup with little to maintain. The trade-off is that you rely on one platform.
What you need before you start
- Node.js 22 or newer. Check with
node -v. - A Cloudflare account. The Workers Free plan is enough to start.
- R2 switched on. In the Cloudflare dashboard open R2, then Overview, and accept the terms. R2 asks for a payment method, but its free allowance covers most small sites.
- A way to send email. SharpWrite signs you in with an emailed link instead of a password, so it needs a Resend API key (it starts with
re_). - Your license key and download link, from your purchase email.
The install
Download the bundle from your email, unzip it, open a terminal in the sharpwrite folder and run:
npm install
npm run setupThe setup script does the rest. It logs you in to Cloudflare, asks for your license key and Resend key, creates the D1 database and the R2 bucket, creates the tables, builds the site and deploys it. It is safe to run again: it reuses what exists and only changes what is missing, so if it stops halfway you fix the problem and run it again.
If you prefer no prompts, pass the answers as flags:
npm run setup -- --license-key SW-XXXXX-XXXXX-XXXXX-XXXXX --resend-key re_xxxx --email-from "My Site <hello@example.com>"Add your own domain
A SharpWrite license has no domain limit. Everything runs on your own Cloudflare account, with your own database and storage, so you can host as many sites as you like on it.
To put a site on your own domain, go to Workers & Pages in the Cloudflare dashboard, open your Worker, then Settings, Domains & Routes, and add a custom domain.
Create your account
Open https://your-site/setup, enter your license key, your email address and a site name. This only works once, and only with the license key, so a stranger who finds a fresh install cannot claim it.
Then visit /status. It shows whether the database, media storage and license are connected, and never shows secrets.
One thing to know: until you verify a sending domain in Resend, it only delivers to your own address. Verify your domain, then set --email-from to an address on it.
Connect your site
Once you have an account, create a content type (for example posts), write an entry, publish it and create an API key. Your site reads published content with one request:
curl https://your-site/api/public/v1/posts \
-H "Authorization: Bearer sw_live_YOUR_KEY"The API is the same on Self-host and on Cloud, so any front-end guide works for both. Our Astro walkthrough shows the full code.
What it costs
Cloudflare pricing and free allowances change, so check the current Workers, D1 and R2 pages rather than trusting a number in a blog post. In general:
- A small, mostly-read site often fits within free allowances.
- If a busy site hits a CPU time error (Cloudflare error 1102), you move the Worker to the paid Workers plan.
- R2 needs a payment method on file even when you stay inside the free allowance.
Add the license itself to the total. Our three-year cost breakdown compares this against a monthly plan.
Updates and upkeep
Self-hosting means you own the updates. With SharpWrite Self-host, a license includes one year of updates. To update, download the newest bundle, copy your wrangler.jsonc over the new one (it holds your database id) and run npm install and npm run setup again. Your content stays in your database. After the first year the software keeps working; you just do not get newer releases.
Keep an eye on three things: the license check (it runs about once a day and keeps working for 14 days if the license server cannot be reached), your Resend sending domain, and your Cloudflare plan limits.
When self-hosting is the wrong choice
Be honest about it:
- You do not want any responsibility for updates or deployment.
- You want the built-in AI tools, which are part of the Cloud plan and not Self-host.
- You publish so rarely that a monthly plan is cheaper than your time.
In those cases a hosted plan is the better deal. You can start with a 7-day free trial on Cloud and move to a self-host license later, because the content model and the API are the same.
Troubleshooting
- "Setup stopped: ..." Read the message, fix the cause and run
npm run setupagain. It continues where it stopped. - R2 must be switched on. Accept the terms under R2, Overview, then re-run setup.
- Editing is off but content still loads. The license check failed. The banner in the admin says why.
Frequently asked questions
Can I self-host a CMS without a server?
Yes. On Cloudflare the code runs on Workers, the database is D1 and files live in R2, so there is no server or container for you to manage. You deploy with a command and Cloudflare runs the infrastructure.
Do I need Docker to self-host SharpWrite?
No. SharpWrite Self-host runs on Cloudflare Workers, D1 and R2, with a guided setup script. You need Node.js 22 or newer and a Cloudflare account, and nothing else to install.
How long does the setup take?
About fifteen minutes for most people, including creating the Cloudflare resources and verifying an email key. Verifying a sending domain with your email provider can take longer.
Is Cloudflare self-hosting free?
The Workers Free plan is enough to start, and a small site often stays within the free allowances. R2 needs a payment method on file. Check Cloudflare's current pricing, and add the cost of the CMS license to your total.
What happens to my content if the license ends?
Your content stays in your own D1 database and R2 bucket. If a license is refunded or switched off, editing is turned off, but the public API and your media keep working so your live site does not go down.
Can I move from Cloud to Self-host later?
Yes. The content model and the API are the same, and the table names match, so you can move content between the two editions.