BEN/TRANBook Discovery Call
Back to Work
Live ProductLaunch Live App

Kōhī Roasters: Serverless E-Commerce & Live Stripe Edge Checkout

An artisanal coffee storefront engineered with Next.js static edge rendering and Cloudflare Pages Functions for sub-second Stripe payment sessions.

Checkout

Stripe Live

Edge Worker

Sub-50ms Exec

Infrastructure

$0 / Month

Built With:Next.jsCloudflare Pages FunctionsStripe APITailwind CSSStatic Export
Stripe LiveCoffee Store

Ethiopia Roast

$22.00 • Whole Bean

Pay with Stripe →

Traditional e-commerce platforms force business owners into a difficult compromise: pay monthly subscription fees for monolithic platforms (like Shopify), or manage fragile, slow, database-driven sites (like WooCommerce) that crash during traffic spikes.

For Kōhī Roasters, an artisanal coffee roaster, I engineered a third path: a 100% serverless, static-first e-commerce engine. By pairing a statically pre-rendered Next.js storefront with a Cloudflare Pages Function at the edge, Kōhī achieves sub-second page loads globally and instant live Stripe Checkout with zero monthly hosting costs.

Instant Checkout Pipeline: Selections transition to Stripe's hosted checkout in sub-500ms.

The E-Commerce Performance Crisis

Most coffee and specialty retail websites are weighed down by dynamic server overhead. Every time a customer browses a product, the server must query a database for pricing and run dozens of marketing plugins.

This results in a Time to First Byte (TTFB) of 1,500ms to 3,000ms on mobile connections. When impulse buyers are looking for fresh coffee, a 3-second delay means abandoned carts and lost revenue.

"A 100ms delay in website load time can decrease e-commerce conversion rates by 7%. Speed is not a luxury feature—it is your primary sales funnel."

Edge Worker Architecture

Instead of renting a centralized server or paying monthly SaaS fees, I built the API checkout layer using Cloudflare Pages Functions.

When a customer clicks "Pay with Stripe", the browser sends a lightweight POST request containing their cart items to an edge worker function running in a data center nearest to the user.

functions/api/checkout.ts
export const onRequestPost: PagesFunction<Env> = async (context) => {
  const secretKey = context.env.STRIPE_SECRET_KEY;
  const { cart } = await context.request.json();

  // Call Stripe API directly using native edge fetch
  const stripeResponse = await fetch(
    "https://api.stripe.com/v1/checkout/sessions",
    {
      method: "POST",
      headers: {
        Authorization: `Bearer ${secretKey}`,
        "Content-Type": "application/x-www-form-urlencoded",
      },
      body: body.toString(),
    },
  );

  const session = await stripeResponse.json();
  return new Response(JSON.stringify({ url: session.url }));
};
Specialty Coffee Product Detail UI
Pixel-Perfect Product Catalog: Sub-100ms rendering with responsive product cards.

Enterprise Security & PCI Compliance

By leveraging Cloudflare Pages Functions for payment processing, I achieved bank-level security without maintaining server infrastructure:

  • Zero Secret Exposure: The Stripe secret key is securely injected into Cloudflare's encrypted environment variables. It is never exposed to the client-side JavaScript bundle.
  • Serverless PCI Compliance: No credit card numbers touch Kōhī's servers. Payment processing is delegated directly to Stripe's PCI-DSS Level 1 certified infrastructure.
  • Server-Timing Telemetry: The edge function outputs native Server-Timing headers, allowing us to monitor edge worker execution duration (~15ms) vs Stripe API latency (~200ms) in real time.

Edge Function Execution

Sub-50ms

Cloudflare's serverless edge workers construct Stripe payment sessions instantly from hundreds of global locations.

Business Impact & ROI

By replacing traditional e-commerce bloat with a static Next.js export and serverless edge functions, Kōhī Roasters achieved:

  • 100/100 Core Web Vitals: Flawless mobile rendering and instant page loads.
  • $0 / Month Infrastructure: Zero server costs, zero plugin renewal fees, and zero database maintenance.
  • Unbreakable Reliability: The site cannot crash during promotional emails or social media surges because there is no database to overload.

Need a similar architecture?

Let's discuss how to engineer a custom system for your business.

Book Discovery Call