Build a Storefront with Medusa.js Under $50/Month

by Emma Rodriguez
Build a Storefront with Medusa.js Under $50/Month

You're staring at your Shopify bill — again. Maybe it's the 2% transaction fee eating into your margins, or the $79/month plan you upgraded to just to unlock a single feature. Either way, you're doing the math in your head and thinking: there has to be a better way.

There is, and it's called Medusa.js. It's an open-source headless commerce engine that lets you own your backend, pick your own frontend, and pay only for the hosting you actually use. I ran the numbers on my second store before migrating, and the stack I'll walk you through today costs me between $30 and $45 a month — including a managed database, CDN, and a Next.js storefront. That's not a promo rate; that's a steady-state bill.

This tutorial is for you if you're comfortable clicking around a terminal, have a store doing somewhere between $5K and $50K a month, and are tired of paying a platform tax for features you don't use. You don't need to be a developer — but you do need to be willing to follow steps carefully and Google an error message or two.

What Medusa.js Actually Is (Plain English)

Headless commerce sounds intimidating, but the idea is simple: you split your store into two pieces. The backend handles products, orders, customers, payments, and inventory — that's Medusa. The frontend is the website your shoppers see — that's whatever you want it to be, most commonly a Next.js app.

They talk to each other through an API (think of it as a menu at a restaurant: the kitchen doesn't care how the dining room is decorated, it just fulfills orders). Because the two sides are separate, you can redesign your storefront without touching your order logic, or add a mobile app later without rebuilding anything.

Medusa itself is free. You pay only for the servers that run it. That's the whole value proposition.

The $50/Month Stack You'll Actually Use

Before you write a single line of config, let's talk money. Here's the exact stack and what each piece costs:

  • Railway (Medusa backend + PostgreSQL database): ~$10–15/month on their Hobby plan, which covers a small Node.js service and a managed Postgres instance with daily backups.
  • Vercel (Next.js storefront): Free on the Hobby tier for most SMB traffic levels. If you're pushing past 100GB of bandwidth a month, you'll hit ~$20/month on Pro — still reasonable.
  • Redis on Railway: ~$5/month for the cache layer Medusa uses for sessions and queues.
  • Stripe for payments: No monthly fee; 2.9% + 30¢ per transaction, which you'd pay on any platform.
  • Cloudflare (DNS + free CDN tier): $0.

Total fixed cost: $15–20/month at low traffic, scaling to around $40–45/month as you grow. Compare that to Shopify Advanced at $299/month before apps.

Is this stack more hands-on than Shopify? Yes, by about two hours of setup time. Is it worth it once it's running? For most stores I've talked to, absolutely.

Step 1: Spin Up Your Medusa Backend on Railway

Railway is the friendliest place to host a Node.js app if you're not a DevOps person. Here's the sequence:

  1. Create a free Railway account at railway.app.
  2. Click New Project → Deploy from GitHub repo. If you don't have a Medusa repo yet, fork the official medusajs/medusa-starter-default on GitHub first — it takes 30 seconds.
  3. Railway will detect it's a Node.js app. Set your start command to medusa start and your build command to npm run build.
  4. Add a PostgreSQL plugin inside Railway (one click). Railway automatically injects a DATABASE_URL environment variable into your app — Medusa reads this natively.
  5. Add a Redis plugin the same way. Set the REDIS_URL environment variable.
  6. Add these additional environment variables in Railway's dashboard:
    • JWT_SECRET — any long random string (use a password generator)
    • COOKIE_SECRET — same idea, different string
    • NODE_ENV=production
  7. Hit Deploy. Railway builds and starts your backend. The first deploy takes about 3–4 minutes.

Once it's live, Railway gives you a public URL like your-app.up.railway.app. Hit your-app.up.railway.app/health in your browser — if you see {"status":"ok"}, your backend is running.

Now run the seed command to populate your store with test data: in Railway's terminal tab, run medusa seed --seed-file=data/seed.json. You'll have sample products in under a minute.

Step 2: Deploy Your Next.js Storefront on Vercel

Medusa maintains an official Next.js starter called medusa-next-js-starter. It's not the prettiest storefront out of the box, but it's fully functional and a solid base to customize.

  1. Fork medusajs/nextjs-starter-medusa on GitHub.
  2. Go to vercel.com, click Add New Project, and import your fork.
  3. Vercel detects Next.js automatically. Before you deploy, add one environment variable:
    • NEXT_PUBLIC_MEDUSA_BACKEND_URL = your Railway backend URL (e.g., https://your-app.up.railway.app)
  4. Click Deploy. Vercel builds and publishes your storefront in about 90 seconds.

Visit your Vercel URL. You should see a working storefront with your seeded products. Click through to a product page, add to cart, proceed to checkout. Stripe's test mode is active by default — use card number 4242 4242 4242 4242 with any future expiry to simulate a purchase.

Did the checkout work? Good. You just ran your first headless commerce transaction.

Step 3: Connect a Real Domain and Lock Down Your Admin

Two things people often skip that come back to bite them:

Custom domain: In Vercel, go to your project settings → Domains, add your domain, and update your DNS records (usually two CNAME entries). Cloudflare makes this painless and adds a free SSL cert and CDN layer on top. Total time: 15 minutes, most of which is DNS propagation.

Admin panel security: Medusa ships with an admin dashboard at /app on your backend URL. By default, it's wide open to anyone who knows the URL. Create your admin user by running this in Railway's terminal:

medusa user -e you@yourdomain.com -p YourStrongPassword

Then in Railway, set the environment variable ADMIN_CORS to your actual admin domain (e.g., https://admin.yourdomain.com) and STORE_CORS to your storefront domain. This tells Medusa to reject requests from anywhere else — a simple but effective security layer. While you're in the environment variables, also set STRIPE_API_KEY and STRIPE_WEBHOOK_SECRET from your Stripe dashboard. Medusa's Stripe plugin reads these automatically, though you should also review this guide on staying safe with public WiFi if you're managing your store from coffee shops or other public networks.

A Quick Real-World Example

Let me tell you about a candle brand I know — 11 SKUs, mostly repeat customers, doing about $18K/month. They were on Shopify Plus (yes, Plus — their agency talked them into it) at $2,300/month including apps. After migrating to this exact Medusa stack, their infrastructure bill dropped to $38/month. They kept their Klaviyo integration (Medusa has a community plugin), their Stripe setup transferred in an afternoon, and they rebuilt their storefront in Next.js over two weekends.

The migration wasn't zero effort. They spent maybe 20 hours total, spread across a month. But $2,262/month in savings paid for a lot of hours.

Your situation might be different — maybe you need a specific Shopify app that has no Medusa equivalent yet, or you genuinely don't want to touch a terminal. That's a real constraint, not a failure. Medusa isn't for every store. But if you're reasonably technical and margin-conscious, the math is hard to argue with.

Three Things to Do Before You Go Live

Once your test checkout works and your domain is connected, run through this checklist before you flip the switch on real traffic:

  1. Set up a Medusa webhook in Stripe: In your Stripe dashboard, add a webhook pointing to https://your-backend.up.railway.app/hooks/payment/stripe. Select the payment_intent.succeeded and payment_intent.payment_failed events. This is how Medusa knows an order actually went through.

  2. Enable Railway's auto-scaling or set a restart policy: Under your service settings, turn on Restart on failure. Railway will automatically restart your Medusa process if it crashes — important for a production store.

  3. Test on mobile: Vercel's Next.js starter is responsive, but check your actual product pages on a real phone. Tap through the checkout flow. Fix anything that feels clunky before customers see it. A 1-second delay on mobile checkout can drop conversion by 7% — that's not a number to ignore.

You're Closer Than You Think

Here's the honest truth: most people who look at headless commerce assume it's only for engineering teams at funded startups. But the tools have gotten genuinely good in the last two years. Medusa's documentation is clear, Railway abstracts away the scary server stuff, and Vercel handles deployment so smoothly it almost feels like cheating.

If you follow the steps above, you can have a working storefront — real products, real checkout, real domain — in a single Saturday afternoon. Your ongoing bill will be a fraction of what a hosted platform charges, and you'll own every piece of your stack. This comparison on Core Web Vitals is also worth reviewing if you want to optimize your storefront's performance for search rankings.

Your next step: fork the medusa-starter-default repo right now, even if you don't deploy it today. Just poke around the file structure. Once you see how straightforward the config files are, the whole thing stops feeling like a big leap and starts feeling like a very manageable project.

You've got this.