Case Study: Building an E-commerce Store from Scratch
How we built a custom headless e-commerce store using Next.js App Router, Tailwind CSS v4, and the Shopify Storefront API.
The Challenge: Speed and Customization
Monolithic e-commerce platforms can sometimes limit customization and impact page speed due to render-blocking scripts and unoptimized asset loading. For this project, the client's store had a mobile page load time of 4.8 seconds, leading to drop-offs. The goal was to build a custom storefront that achieved sub-second load times while maintaining catalog flexibility.
The Solution: Headless Architecture
We implemented a headless architecture to separate the presentation layer from the back-office database. Next.js manages the frontend, while Shopify handles catalog data, inventory, and secure checkouts via the Storefront API. This approach allows us to optimize asset delivery, use modern CSS features, and pre-render pages statically.
- Frontend framework: Next.js App Router using React Server Components (RSC) to minimize client-side JavaScript.
- Styling: Tailwind CSS v4 for utility-first layouts and fast CSS compilation.
- Data Fetching: Shopify Storefront GraphQL API with tag-based revalidation.
- Hosting: Vercel for edge network caching and static page regeneration.
Integrating the Shopify Storefront GraphQL API
We set up a helper module to handle Shopify API requests. It supports Next.js fetch cache tag revalidation. When products are updated in Shopify, a webhook triggers a revalidation event to update the static pages without requiring a full build.
export async function shopifyFetch<T>({
query,
variables
}: {
query: string;
variables?: Record<string, any>
}): Promise<T> {
const endpoint = process.env.SHOPIFY_STOREFRONT_API_URL!;
const key = process.env.SHOPIFY_STOREFRONT_ACCESS_TOKEN!;
const res = await fetch(endpoint, {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-Shopify-Storefront-Access-Token": key,
},
body: JSON.stringify({ query, variables }),
next: { tags: ["products"] },
});
if (!res.ok) {
throw new Error(`Failed to fetch from Shopify: ${res.statusText}`);
}
const { data, errors } = await res.json();
if (errors) {
throw new Error(`GraphQL Error: ${JSON.stringify(errors)}`);
}
return data;
}Performance Optimization and Core Web Vitals
To achieve fast loading times, we used React Server Components to load product pages on the server and send minimal HTML to the browser. Images are optimized using Next.js Image component to serve modern formats (WebP/AVIF) and use lazy loading. As a result, the Largest Contentful Paint (LCP) decreased to 0.8 seconds, and conversion rates improved by 28% in the first month.
“Separating the frontend from the e-commerce database gives developers complete control over performance and design. Moving to Next.js improved the site performance score to 98 and significantly increased conversions.”
— Suraj Randhari
Conclusion
Headless commerce offers benefits for businesses aiming to optimize speed, design flexibility, and search engine visibility. Using Next.js alongside the Shopify Storefront API enables developers to build custom storefronts that combine performance with reliability.
Related Articles
Step-by-Step Guide to Launching Your First Shopify Store
Learn how to establish a successful Shopify store from scratch. This comprehensive guide covers catalog setup, payment gateways, theme styling, and checkout optimization.

Subscribe to the developer digest
Stay updated with technical articles, performance deep-dives, design patterns, and case studies. Sent once a month. No spam.
