Course Platform

Build a Course Platform on Cloudflare

Build a paid video course platform with Cloudflare Workers, R2, D1, auth, Stripe, and paywalls.

4 chapters · about 108 min end to end

  1. The Stack & The Bill — Build a Course Platform on Cloudflare for $0 (and What Changes at Scale)The complete budget-first architecture for shipping a paid video-course site on Cloudflare — the exact stack this site runs on. The whole architecture in one picture (Worker + R2 for video + D1 + KV + Stripe + Google OAuth), why each piece beats the heavyweight alternative (R2 vs Stream, Workers vs Lambda, D1 vs Postgres, Stripe Payment Links vs Apple IAP, Google OAuth vs Auth0), the bill at three scales (hobbyist / real product / scaling — $0 / ~$10 / ~$80 per month), and the exact graduation triggers that tell you when to swap each piece for the heavier version.Intermediate · 26 min
  2. Streaming Video on R2 — The $0-Egress Budget WorkaroundThe full deep-dive on Cloudflare R2 as a budget alternative to Cloudflare Stream / Mux / Cloudinary for a course site. The real cost math (R2 vs Stream at three scales — order-of-magnitude cheaper for small libraries), the upload pipeline (ffmpeg encoding cheat sheet, wrangler upload, multipart for big files), the two ways to serve (public bucket for free previews, Worker proxy for auth-gated paid content with a complete code example), MP4 progressive vs HLS adaptive bitrate (which to pick when), custom domains on R2, the byte-range protocol that makes seeking work, and the exact moment Stream stops costing more and starts being worth it.Intermediate · 28 min
  3. Auth + Stripe Subscriptions — Who They Are & What They Paid ForThe gate layer of a Cloudflare course platform: Google OAuth in a Worker (in ~100 lines, no Auth0 vendor), JWT session cookies the right way (HttpOnly + SameSite + Web Crypto signing — no Node bcrypt), Stripe Payment Links so checkout is one URL and your Worker holds zero card data, the webhook handler that verifies Stripe's signature and updates D1, the D1 schema for subscriptions, and the one-line `isSubscribed(userId)` function the rest of the app calls. Plus the Apple-IAP-avoidance argument with real numbers — ~3% Stripe vs ~30% Apple is ~$30k/year on a thousand-subscriber product.Intermediate · 30 min
  4. The Paywall — Server-Side Gates for Videos and SEO-Safe Article PaywallsThe policy layer that turns Ch 2's video Worker and Ch 3's `isSubscribed` into a complete paid-content site. The hard gate for videos and premium APIs (401 / 402 / 200, declarative free-vs-Pro manifest, why it must be server-side), the soft 'count-based' paywall for articles (5 free reads → CSS-blur overlay, full HTML stays in the DOM so Google still indexes you), the free-preview pattern that boosts conversion, restore-on-other-device flows, gift codes and trials, the Apple-app-on-top edge case (custom URL scheme to refresh entitlement instantly after Stripe success), and the small list of things people forget — Cache-Control: private, the right HTTP status codes, and not storing anything Stripe already does.Intermediate · 24 min

Read next

Cloudflare Feature FocusProduction Web Apps SeriesModern Delivery Pipeline