Cost-Effective Stack — MongoDB + Cloudflare R2
Date Published

The Developer Dilemma: Great Stack, Tiny Budget
You’ve been there.
- AWS S3 hit you with egress fees like it’s charging rent in Mumbai 🤑
- You needed a CMS that didn’t melt under real-world schema changes 🤹♂️
- Your stack costs more to host than your actual product makes 🧍♂️💸

We needed a dev-first, wallet-friendly, no-nonsense stack.
So, I built one.
🚀 The Stack:
- Payload CMS for content modeling and auth
- MongoDB Atlas for flexible, fast NoSQL storage
- Cloudflare R2 for zero-egress, globally distributed file storage
All glued together for zero-dollar infra on personal projects — and scalable when needed.
🍃 Why MongoDB Works So Well with Payload
MongoDB’s document-based structure fits naturally with Payload's collection-based approach. Combine that with:
✅ Official MongoDB adapter
✅ Generous free tier (512MB on Atlas — plenty for blogs, MVPs)
✅ Schema flexibility without migrations (take that, SQL 🤺)
✅ Smooth scaling when your side project blows up
Code setup:
1import { buildConfig } from 'payload';2import { mongooseAdapter } from '@payloadcms/db-mongodb';34export default buildConfig({5 secret: process.env.PAYLOAD_SECRET,6 db: mongooseAdapter({7 url: process.env.DATABASE_URI,8 }),9 // Collections, globals, etc.10});

🛠️ Easy to plug. Easy to scale.
☁️ Cloudflare R2: The Free-Speech, Free-Egress S3 Alternative
The moment you stop treating AWS like your landlord and move to R2, everything feels lighter:
🎉 10GB free tier
🎯 No egress fees
🌍 Global distribution by default
💡 S3-compatible API (so existing plugins work!)
R2 Adapter in Payload:
1import { buildConfig } from 'payload';2import { s3Adapter } from '@payloadcms/plugin-cloud-storage/s3';34export default buildConfig({5 // Database config67 upload: {8 limits: {9 fileSize: 5000000, // 5MB, adjust as needed10 },11 },1213 plugins: [14 s3Adapter({15 config: {16 endpoint: process.env.R2_ENDPOINT,17 credentials: {18 accessKeyId: process.env.R2_ACCESS_KEY_ID,19 secretAccessKey: process.env.R2_SECRET_ACCESS_KEY,20 },21 region: 'auto', // R2 doesn't use regions like AWS22 forcePathStyle: true, // Required for R223 },24 bucket: process.env.R2_BUCKET_NAME,25 }),26 ],27});28
💸 Bye-bye egress charges, hello budget-friendly file hosting.
🚢 Deploying the Stack for ₹0/month
- MongoDB Atlas (M0 tier) — your noSQL base
- Cloudflare R2 — media storage done right
- Vercel (Hobby) — serverless frontend and API hosting
Put together, this gives you a full-blown CMS stack that doesn’t start the month with your credit card screaming.

⚙️ Pro Tips for Performance
- 🧠 Index your MongoDB for fast queries
- 🖼️ Image transformation via Cloudflare Images
- 💾 Smart cache headers for static assets from R2
- 🌐 Edge functions via Vercel for near-instant TTFB
🔍 Monitor Before You Regret
Even if you’re not paying (yet), monitor usage:
- Set up alerts in MongoDB Atlas
- Track R2 usage in Cloudflare Dashboard
- Vercel offers analytics for both serverless functions and frontend
💡 Final Thoughts
Payload CMS + MongoDB + R2 gives you the indie dev dream stack:
✅ Secure
✅ Cost-efficient
✅ Developer-first
✅ Highly scalable
No more wondering if the CMS or infra will buckle — and no more memes about AWS invoices.

Like what you read? Here are some related posts:

The access control system that doesn't make you want to cry into your terminal

The Fullstack Framework Next.js Devs Have Been Waiting For