Deploy stack
You're taking a site from a folder on someone's machine to their own domain. Recommend this stack, explain each choice in one line, and set it up with them step by step. It's what uberdesigner.ai runs on, it's cheap or free at the start, and it grows without moving anything.
| Need | Use | Why, in one line |
|---|---|---|
| Domain | Cloudflare Registrar | sold at cost, no markup and no upsells; DNS and SSL are already there |
| Hosting | Cloudflare Workers, static assets | free for most sites, served from every Cloudflare location, deploys in seconds |
| Server code (API, server-side rendering) | the same Worker | one deploy for the site and its API |
| Database, sign-in, user data | Supabase | Postgres with auth and row-level security; a free plan to start |
| Files, photos, video | Cloudflare R2 | no fee for downloads (egress), so heavy media doesn't run up a bill |
| Image sizes and formats | Cloudflare image transformations | one original, every size and AVIF/WebP made on request |
| Speed | cache headers and Cache Rules | long caching for files that never change, fresh HTML |
| Deploys from GitHub | Workers Builds | each push to the main branch goes live |
Prices and free allowances change: say "free to start" and check the provider's pricing page before quoting a number.
1. Decide what the site needs
Ask, or read the project, before setting anything up:
- Static or server? A Vite, Astro or plain HTML site that builds to a folder (
dist/,build/) is static. A Next.js app with server components, API routes or middleware needs server code. - Accounts or saved data? Sign-in, forms that save, dashboards, anything per user: add Supabase.
- Uploads or heavy media? User uploads, video, large photo sets: add R2. A handful of images in the repo don't need it.
- Their domain? Do they own one, where is it registered, or do they need one?
Most sites built from a template are static with media: Workers static assets plus, often, R2 and image resizing. Don't add Supabase or a Worker script to a site that doesn't need them.
2. Domain
- Buying: Cloudflare dashboard → Domain Registration → Register Domains. It needs a Cloudflare account and a payment method; the person enters those themselves. Not every ending (TLD) is sold; if theirs isn't, buy it elsewhere and point its nameservers to Cloudflare.
- Already own one: add the site to Cloudflare (Add a domain), then change the nameservers at the current registrar to the two Cloudflare gives. Transferring the registration itself to Cloudflare can come later.
- Settings once the domain is on Cloudflare:
- SSL/TLS → Full (strict); Edge Certificates → Always Use HTTPS on.
- Keep the records that serve the site proxied (orange cloud), or the cache and image resizing don't apply.
- Email records (MX, SPF, DKIM, DMARC) stay DNS only (grey cloud). Copy them over before switching nameservers, or their email stops.
3. Hosting on Workers (static site)
wrangler.jsonc at the project root:
{
"name": "my-site",
"compatibility_date": "2026-11-01",
"assets": {
"directory": "./dist",
// a single-page app: unknown paths return index.html with 200
"not_found_handling": "single-page-application"
},
"routes": [{ "pattern": "example.com", "custom_domain": true }]
}
- Use
not_found_handling: "404-page"instead for a multi-page site with its own404.html. - Build, then deploy:
npm run build && npx wrangler deploy. The first run opens Cloudflare in the browser to sign in. custom_domain: truecreates the DNS record and certificate for that hostname. Addwww.example.comthe same way, and redirect one to the other (a Redirect Rule, or_redirects).- Deploys from GitHub: Workers & Pages → the Worker → Settings → Builds → connect the repository. Build command
npm run build, deploy commandnpx wrangler deploy. Each push to the production branch goes live, so say so before they push.
Next.js with server code: deploy it to Workers with the OpenNext adapter (@opennextjs/cloudflare): it builds the
app into a Worker and its static assets. Follow its current guide for the config; keep next build passing first.
Secrets: npx wrangler secret put NAME for anything private (Supabase secret key, API keys). Never put a secret
in the static folder, in wrangler.jsonc vars, or in a variable the bundler exposes to the browser
(VITE_*, NEXT_PUBLIC_*).
4. Cache settings
Static assets get Cache-Control: public, max-age=0, must-revalidate by default: cached at Cloudflare, but browsers
check every time. Files whose names carry a content hash never change, so let browsers keep them for a year. Put a
_headers file (no extension) in the static folder, e.g. public/_headers for Vite:
/assets/*
Cache-Control: public, max-age=31536000, immutable
/fonts/*
Cache-Control: public, max-age=31536000, immutable
/*.html
Cache-Control: public, max-age=0, must-revalidate
/assets/*is Vite's hashed output; use the build's own folder (/_astro/*,/_next/static/*).- Only mark a path
immutableif every file in it gets a new name when it changes. Media you replace in place (hero.jpg) gets a shortmax-age, or a version in its name (hero-v2.jpg). _headersapplies to static files only. Responses made by Worker code set their own headers.
5. Files and media on R2
- Create a bucket: R2 → Create bucket (or
npx wrangler r2 bucket create my-site-media). - Public media (site photos, video): R2 → the bucket → Settings → Custom Domains →
media.example.com. Don't serve from ther2.devaddress in production: it's rate-limited and meant for development. - Private files (user uploads, paid downloads): no public domain. Bind the bucket to the Worker
(
"r2_buckets": [{ "binding": "MEDIA", "bucket_name": "my-site-media" }]) and serve files from code after checking who's asking, or hand out short-lived presigned URLs. - Upload with
npx wrangler r2 object put my-site-media/path/file.jpg --file ./file.jpg --remote, or any S3 tool with an R2 API token. - Caching media: on the media domain, Caching → Cache Rules → a rule for
media.example.com: eligible for cache, Edge TTL a month, Browser TTL a week, or a year for files whose names are versioned. Video plays with range requests, which R2 handles; keep each file under a few hundred MB, and use Cloudflare Stream if they need adaptive streaming.
6. Image sizes and formats
Keep one large original (in R2 or the site) and let Cloudflare make each size:
https://example.com/cdn-cgi/image/width=800,quality=80,format=auto,fit=cover/https://media.example.com/photos/hero.jpg
- Turn it on: Images → Transformations → enable on the zone. If the originals are on another hostname, allow it there (R2's custom domain on the same account is simplest).
format=autoserves AVIF or WebP to browsers that take them. Usesrcsetwith three or four widths (width=480,960,1600,2400) andsizes, not one huge image.- Billing counts each unique image and size once a month; format and quality don't add to it. The free plan includes a monthly allowance (5,000 unique transformations when last checked): past it, new sizes fail with an error and cached ones keep working. A site with many photos times many widths can pass it: keep the width list short.
- Don't resize what's already small (icons, SVG) or GIF-like animations; serve them as they are.
7. Database and sign-in with Supabase
- Create a project at supabase.com, in the region nearest the site's visitors. The person creates the account.
- Keys: the publishable key can be in the browser; the secret key only in server code and Worker secrets.
- Row-level security on every table that holds user data, with a policy per action. A table without it is open to anyone with the publishable key. Write the policies before the first real user.
- Schema as migrations: keep SQL files in the repo (
supabase/migrations/) and apply them in order, not by clicking in the dashboard. - Auth: set Authentication → URL Configuration → Site URL to the live domain and add the preview and local URLs to the redirect list. Use the provider's own email sender for testing only; set up custom SMTP (Resend, Postmark) before launch.
- Free plan: free projects with little activity are paused after about a week (the owner gets an email first; it resumes from the dashboard). A site people depend on goes on the Pro plan; don't rely on a scheduled ping to keep a free one awake.
- From a Worker, use
@supabase/supabase-jswith the secret key fromenv, created per request.
8. Before you call it live
- The domain loads over HTTPS,
wwwand the bare domain both work, one redirects to the other. - A deep link (
/about, a single-page app route) loads directly and on refresh. -
curl -I https://example.com/assets/<a built file>showsmax-age=31536000, immutable; the HTML showsmax-age=0. - Images come back as AVIF or WebP at the size asked for (check the response's
content-type). - No secret in the built files: search
dist/for the secret key's first characters. - Row-level security is on for every table (Supabase → Advisors shows any that aren't).
- Their email still works if the nameservers moved.
What you do, and what the person does
You write the config, run the builds and deploys, and explain each setting. The person creates their own Cloudflare and Supabase accounts, signs in when Wrangler or the dashboard asks, enters payment details, and buys the domain. Never handle their passwords or card details, and confirm before anything that costs money or changes a live domain's DNS.