Building a Headless Shopify Store with Remix

Explore Your Brain Editorial Team
Science Communication
Modern commercial brands require distinct, highly immersive shopping environments. Merely utilizing a heavily restricted, standard Shopify Liquid template immediately degrades premium brand positioning.
To architect a truly bespoke application, senior engineering teams embrace "Headless Commerce". You violently decapitate the visual interface from the backend database. You construct an entirely independent React infrastructure (utilizing Remix) and quietly interact with Shopify's inventory systems asynchronously via the GraphQL Storefront API.
1. Generating API Credentials
Within your standard Shopify Administration dashboard, navigate aggressively to "Headless" apps. Generate a Storefront API Access Token. This token is technically safe to expose to the public internet because it possesses exactly zero administrative capabilities; it can merely "read" products and strictly "create" customer carts.
2. Architecting the Remix Loader
Remix natively performs data fetching purely on the backend Node server using an exported loader function aggressively attached to the route. This permanently eliminates CLS (Cumulative Layout Shift) loading spinners for the customer.
import { json } from "@remix-run/node";
import { useLoaderData } from "@remix-run/react";
import { gql, request } from "graphql-request";
// 1. This function ONLY runs reliably on your secure backend server!
export const loader = async () => {
// Securely query the Shopify Storefront GraphQL Endpoint
const query = gql\`
{
products(first: 10) {
edges {
node {
id
title
handle
priceRange {
maxVariantPrice { amount currencyCode }
}
}
}
}
}
\`;
const headers = {
'X-Shopify-Storefront-Access-Token': process.env.SHOPIFY_TOKEN,
};
const response = await request(process.env.SHOPIFY_DOMAIN, query, {}, headers);
// Return securely formatted data directly to the component below
return json({ products: response.products.edges });
};
// 2. This represents the heavily interactive React UI rendered instantly
export default function ProductsPage() {
const { products } = useLoaderData<typeof loader>();
return (
<div class="grid grid-cols-4 gap-6">
{products.map(({ node }) => (
<article key={node.id} class="p-4 border rounded">
<h2>{node.title}</h2>
<p class="font-bold">\${node.priceRange.maxVariantPrice.amount}</p>
<a href={\`/product/\${node.handle}\>View Details
))}
Conclusion
Building custom Headless stores incurs a massive immediate technical debt. You are suddenly liable for maintaining cart sessions and routing logic. However, the immense freedom to utilize bleeding-edge web frameworks dramatically increases conversion performance and unleashes unlimited creative architectural designs that Liquid templates structurally forbid.