Saturday, May 30, 2026

Building a Crypto Store on Cloudflare Pages: The Bare-Bones Guide

Building a Crypto Store on Cloudflare Pages: The Bare-Bones Guide

Introduction

Cloudflare Pages gives us a free static-hosting runway and an edge network that works from Lagos to Nairobi. Combine it with NOWPayments and you get a crypto checkout that requires nothing from Stripe or PayPal. This is the stack I used to launch an e-commerce store in 48 hours—no US bank account, no merchant of record, just three lines of config. Below is the exact sequence that passed KYC, accepted USDT/USDC/BTC, and auto-fulfilled orders without me touching a payment processors dashboard.

Choose the Stack That Fits Your Region

You have two paths, depending on where you are and how much you want to code.

Stack 01 (zero JavaScript) 1. Build the store in Markdown/HTML with any static-site generator—Hugo, Eleventy, Next.js Static export. 2. Push the repo to GitHub. 3. Connect the repo to Cloudflare Pages. In Settings → Build → Build command, set npm run build or hugo. Publish directory is the output folder. 4. Map your domain. Cloudflare will issue the free SSL cert automatically. Stack 02 (edge functions) 1. Same repo as above. 2. Add a single Cloudflare Worker that renders the page and handles the crypto checkout endpoint (/api/checkout). 3. The Worker fetches product info from a KV namespace, crafts an NOWPayments invoice, and returns the checkout URL. No Node.js server needed.

Either way, you own the domain, the repo, and the keys.

Payment Layer Without a Traditional PSP

NOWPayments is the only crypto processor Ive used that accepts users from Nigeria, Kenya, and Ghana without asking for incorporation papers.

Sign-up steps 1. Create an account at nowpayments.io. Choose your currency—USDT (TRC-20) or USDC (Polygon) for lowest fees in Africa. 2. In Dashboard → Store settings, add your Cloudflare domain (https://store.yourdomain.com). 3. Copy the x-api-key header value. 4. In your Worker or frontend code, call POST https://api.nowpayments.io/v1/payment with body: ``` { price_amount: 49.99, price_currency: USD, pay_currency: USDT_TRON, order_id: order-123, order_description: Pink T-shirt, success_url: https://store.yourdomain.com/success?order_id=123, callback_url: https://api.yourdomain.com/webhook/nowpayments } ``` Headers: Content-Type application/json and x-api-key YOUR_KEY.

KYC timing African users often get flagged for higher verification tiers. If your monthly volume exceeds 5 000 USD equivalent, NOWPayments will ask for passport/business docs. Until then, invoices up to 5 000 USD settle without extra steps. Keep your personal limit below the threshold while you grow.

Edge Network Tricks That Save Costs

1. Cache the product JSON at the edge In your Worker, use ``` const productCache = caches.default; let response = await productCache.match(url); if (!response) { response = await fetch(originUrl); response = new Response(response.body, response); response.headers.set('Cache-Control', 's-maxage=300'); await productCache.put(url, response.clone()); } return response; ``` This serves the product list from the closest POP instead of hitting origin on every view.

2. Serve compressed images automatically Cloudflare Pages has built-in Polish. Toggle it in Speed → Optimization → Polish and set to Lossless. African visitors on 4G see the same 2 MB JPEG as desktop users in Europe—no extra CDN cost.

3. Bypass cold starts for the checkout Worker Set a 1-minute keep-alive ping from a free uptime robot to prevent the Worker from sleeping. Latency spikes under 300 ms globally, even in Kampala.

Fulfillment Without a Backend Server

When NOWPayments marks an invoice as paid, it POSTs to your callback_url with the order_id and pay_amount.

Minimal webhook handler in Cloudflare Workers:

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

async function handleRequest(request) { if (request.method === 'POST') { const body = await request.json(); const orderId = body.order_id; const amountPaid = body.pay_amount; const productId = orderId.split('-')[1];

// Update your KV: mark order paid await ORDERS.put(orderId, JSON.stringify({ paid: true, amount: amountPaid, productId: productId }), { metadata: { contentType: 'application/json' } });

// Trigger Telegram or Slack alert const message = `New crypto order ${orderId} for ${amountPaid}` await fetch('https://api.telegram.org/botTOKEN/sendMessage', { method: 'POST', body: JSON.stringify({ chat_id: 12345, text: message }) });

return new Response(null, { status: 200 }); } return new Response('Method not allowed', { status: 405 }); } ```

Stock deductions, shipping emails, and SMS confirmations run from the same Worker—no extra hosting.

Final Checklist Before You Go Live

1. Test invoice flow with 0.0001 USDT to verify webhook signature

TightBucket on one page — where a site loses sales

Conversion leak auditing · Coldcode SI Labs TightBucket TightBucket finds the leaks costi...