CMH Beauty headless commerce storefront
Back to Blog

CMH Beauty: Building a Headless Medusa.js Storefront with Next.js

How we built a blazing-fast headless storefront for CMH Beauty using Next.js, TypeScript, and Medusa.js.

CMH Beauty needed a storefront that was fast, modern, and truly headless. We built them a Next.js frontend that pulls product data from Medusa.js. The result? Lighthouse scores in the 90s and a site that actually feels fast.

Why Headless?

Traditional monolithic e-commerce platforms often come with performance overhead and limited flexibility. Headless architecture lets you control the entire frontend stack while keeping a robust backend for commerce operations.

For CMH Beauty, we went with Next.js 14, TypeScript, and Tailwind CSS. Medusa.js handles the backend (products, cart, orders, payment), and Next.js handles the frontend (routing, rendering, UX).

The Stack

  • Next.js 14+ with App Router and React Server Components

  • TypeScript for type safety across the entire codebase

  • Medusa.js API for products, cart, checkout

  • ISR (Incremental Static Regeneration) for product pages

  • Edge caching with Vercel for global performance

  • Tailwind CSS for styling (no bloated CSS framework)

Performance Wins

Product pages are pre-rendered at build time and revalidated every hour. This means the first visitor gets a cached HTML page—no waiting for the backend to render the page server-side.

Images are optimized automatically with Next.js Image component. We use responsive images, lazy loading, and modern formats (WebP, AVIF) when the browser supports them.

The JavaScript bundle is minimal—only what's needed for interactivity. Clean, modern React with no legacy dependencies.

Challenges

Medusa.js API is well-designed, but you need to be thoughtful about data fetching. We use efficient queries and only request the fields we need. We also batch requests where possible to reduce round trips.

Authentication was interesting—Medusa.js uses JWT tokens, and we needed to handle token refresh, session persistence, and cart merging when users log in.

The Result

Lighthouse performance score: 95+. First Contentful Paint under 1 second. Time to Interactive under 2 seconds. The site feels fast, looks modern, and is genuinely pleasant to use.

If you're considering headless commerce with Medusa.js, it's absolutely worth it—especially if performance and UX are priorities. Happy to chat more about the architecture if you're working on something similar.

Ready to build something fast?

Let's discuss your project.

Get in Touch