Kokil Thapa - Professional Web Developer in Nepal
Freelancer Web Developer in Nepal with 15+ Years of Experience

Kokil Thapa is an experienced full-stack web developer focused on building fast, secure, and scalable web applications. He helps businesses and individuals create SEO-friendly, user-focused digital platforms designed for long-term growth.

Shopify Storefront API for Custom Frontends

By Kokil Thapa | Last reviewed: September 2026

You want a custom storefront that does not look like every other Shopify theme. The Shopify Storefront API for custom frontends is how you get there. It exposes catalog, cart, and checkout data over GraphQL so your Vue app, Laravel Blade site, or static site can sell products while Shopify handles inventory and payments. I've used it on international florist builds and on WooCommerce and Shopify eCommerce projects where the client needed a branded experience outside Liquid. This guide covers auth, queries, cart flow, stack choices, and the production mistakes that break launches.

What Is the Shopify Storefront API for Custom Frontends?

The Storefront API is Shopify's customer-facing GraphQL layer. It sits beside the Shopify Admin API, but the two APIs serve different jobs. Admin API manages products, orders, and settings from your backend. Storefront API serves buyers on the web.

Every response is GraphQL. You request only the fields you need. That keeps payloads small on mobile networks, which matters for Nepal buyers on 4G. The API version follows Shopify's quarterly release cycle. Pin to 2026-07 or later in production so you are not running stale schemas.

A headless setup typically looks like this: your frontend talks to Storefront API, Shopify hosts checkout, and optional middleware handles webhooks through Admin API. You do not rebuild payment processing. You rebuild the shopping experience.

Headless Shopify ArchitectureCustom FrontendVue, Blade, staticStorefront APIGraphQL 2026-07Shopify CoreCatalog, checkoutAdmin API (server only)Webhooks, order sync, private appsBuyer completes payment on hosted Shopify Checkout
Shopify Storefront API for custom frontends: your UI layer, Shopify's commerce engine, Admin API for backend sync

Storefront API access is scoped to unauthenticated buyer actions plus cart management. It cannot delete products or refund orders. That boundary is intentional. You can safely expose the Storefront token in browser code. Never expose Admin API credentials the same way.

What the API exposes

  • Catalog: products, collections, variants, metafields, and search
  • Cart: create cart, add lines, update quantities, apply discount codes
  • Checkout: cart returns a checkoutUrl for hosted payment
  • Customer: login and account data when using customer access tokens
  • Localization: markets, currencies, and translated content

If you need full order management from your app, pair Storefront API with Admin API on a secure server. That pattern mirrors headless Magento REST setups where storefront and admin layers split cleanly.

How Do You Authenticate and Configure the Storefront API?

Setup starts in Shopify Admin. Create a custom app or use the Headless channel. Shopify generates a Storefront API access token and your shop domain. Those two values are enough for read-only catalog calls.

For cart mutations from the browser, also note the API version path. Requests go to a single endpoint:

POST https://{shop}.myshopify.com/api/2026-07/graphql.json
Content-Type: application/json
X-Shopify-Storefront-Access-Token: {your_public_storefront_token}

{
  "query": "{ shop { name } }"
}

Official docs live at shopify.dev/docs/api/storefront. Bookmark the version picker. Breaking schema changes arrive every quarter.

Step-by-step app setup

  1. In Shopify Admin, open Settings → Apps and sales channels → Develop apps.
  2. Create an app and enable Storefront API scopes you need: unauthenticated_read_product_listings, unauthenticated_write_checkouts, and related cart scopes.
  3. Install the app on your store and copy the Storefront access token.
  4. Store the token in frontend env vars such as VITE_SHOPIFY_STOREFRONT_TOKEN for Vite 8.x builds.
  5. Pin API version 2026-07 in your client wrapper so upgrades are deliberate.

On a production Laravel or Node proxy, you can hide the token behind your own API layer. That adds rate-limit control and logging. Direct browser calls are simpler and officially supported for Storefront tokens.

GraphQL Request Pipeline1. Query build2. POST /graphql3. Validate4. JSON dataHeaders on every requestX-Shopify-Storefront-Access-Token + Content-TypeErrors arrayGraphQL 200 with errorsData objectPartial success possible
Every Storefront API call is a POST with a GraphQL query or mutation; always inspect the errors array

Use the JSON formatter when debugging responses during development. GraphQL errors often return HTTP 200 with an errors key. Treat that as a failed call.

How Do You Build Product Pages and Cart Flows with GraphQL?

Product listing starts with a collection or search query. Request handles, prices, and variant IDs. The variant ID is what cart mutations require. Slugs alone are not enough.

Fetch a product by handle

query ProductByHandle($handle: String!) {
  product(handle: $handle) {
    title
    descriptionHtml
    featuredImage { url altText }
    variants(first: 20) {
      edges {
        node {
          id
          title
          price { amount currencyCode }
          availableForSale
        }
      }
    }
  }
}

Cache product pages aggressively at the CDN layer. Catalog data changes less often than cart state. Use short TTLs or webhook-driven revalidation if you run a Vite 8.x static build.

Create a cart and add a line item

Cart state in modern Shopify headless flows uses the cartCreate and cartLinesAdd mutations. The API returns a cart ID and a checkoutUrl.

mutation CreateCart($lines: [CartLineInput!]!) {
  cartCreate(input: { lines: $lines }) {
    cart {
      id
      checkoutUrl
      lines(first: 10) {
        edges {
          node {
            quantity
            merchandise {
              ... on ProductVariant {
                id
                title
              }
            }
          }
        }
      }
    }
    userErrors { field message }
  }
}

Variables for the mutation look like this:

{
  "lines": [
    {
      "merchandiseId": "gid://shopify/ProductVariant/1234567890",
      "quantity": 1
    }
  ]
}

Persist the cart ID in localStorage or a cookie. Pass it to subsequent cartLinesAdd and cartLinesUpdate calls. Without persistence, every page refresh starts an empty cart. That bug shows up constantly on first headless builds.

Cart to Checkout FlowBrowse PLPcartCreatecartLinesAddcheckoutUrlRedirect buyer to Shopify CheckoutPayments, tax, shipping handled by ShopifyOrder webhookFulfillment sync
Storefront API cart mutations end with a checkoutUrl redirect; order events sync via Admin API webhooks

Markets, currency, and Nepal checkout notes

Multi-currency stores need the @inContext directive or country headers so prices match the buyer's market. On stores selling to Nepal, confirm whether NPR is enabled as a presentment currency. Payment methods still depend on Shopify Payments availability and third-party gateways.

Local gateways like eSewa and Khalti are not native Shopify Checkout options. A common pattern is a hybrid: catalog and cart on headless frontend, then a custom payment step via Shopify custom payment integrations or an external Laravel cart for domestic-only flows. Know that limitation before you promise a fully headless NPR checkout.

For international card checkout, redirecting to checkoutUrl is the path of least resistance. Shopify calculates tax and shipping inside checkout. Your frontend does not reimplement that logic.

How Does the Storefront API Compare to Hydrogen and Liquid Themes?

You have three realistic frontend paths. Each fits a different team and budget. None is universally best.

Approth>StackBest forTrade-off
Liquid themeShopify-hosted templatesFast launch, small budget, standard UXLimited layout freedom, Online Store 2.0 constraints
HydrogenReact + Remix, Shopify SDKTeams committed to React, Oxygen hostingFramework lock-in, steeper ops than static sites
Custom + Storefront APIVue, Blade, Next-like static, mobile webBrand-heavy UI, existing design systemYou own routing, caching, and cart edge cases

Read the dedicated Hydrogen vs custom React storefront comparison if React is already your stack. Hydrogen wraps Storefront API with routing, caching, and Oxygen deploy conventions. A custom frontend uses the same API with your own conventions.

On florist eCommerce builds, Liquid plus heavy customisation often ships faster than full headless. Headless earns its cost when marketing needs a distinct UX, a separate mobile web app, or content from a CMS outside Shopify.

Frontend Stack DecisionNew Shopify store?Standard catalogUse Liquid themeReact teamChoose HydrogenCustom UXStorefront APIAll paths use Shopify Checkout for paymentsHeadless only replaces theme rendering
Pick Liquid for speed, Hydrogen for React-native teams, or raw Storefront API for full UI control

Liquid themes still benefit from custom Liquid development when you stay in-theme. Storefront API is the escape hatch when the theme model itself is the bottleneck.

What Are Common Production Mistakes with Headless Shopify?

Headless Shopify fails in predictable ways. Most are fixable before launch if you plan for them.

Rate limits and query cost

Storefront API uses a calculated query cost bucket, not simple request counts. Deep nested queries burn capacity fast. Flatten product lists. Paginate with cursors. Avoid fetching entire catalogs in one query during SSR.

Shopify documents rate limits in the API usage and rate limits guide. Log query cost headers in staging so you see spikes before traffic does.

SEO and indexation

Headless frontends own URL structure, meta tags, and Core Web Vitals. Shopify's theme SEO defaults disappear. You must render canonical tags, product schema, and sitemaps yourself or through your framework.

That work belongs in the architecture phase, not the week before launch. Pair frontend work with technical SEO review if organic search drives revenue.

Stale inventory and webhooks

Storefront API reads live inventory at query time, but aggressive CDN caching can show sold-out variants. Use shorter cache for PLP cards or listen to inventory_levels/update webhooks via Admin API to purge cache keys.

Mixing Admin and Storefront concerns

A common mistake is calling Admin API from the browser to "fix" missing Storefront fields. That exposes private tokens and violates Shopify policy. If data is missing from Storefront API, expose it via metafields with Storefront visibility, or fetch it server-side.

The GraphQL spec's error handling rules are documented at graphql.org/learn/response. Partial data plus errors is valid GraphQL. Your UI must handle both.

Deployment and preview environments

Point staging frontends at a Shopify development store. Never run cart tests against production with real payment methods enabled. For teams using GitLab CI like my Deployer pipelines on legal-tech sister sites, store tokens in CI variables and inject at build time.

Performance tuning belongs in the same pass as launch. Compress images, lazy-load galleries, and measure LCP on 4G profiles. Speed optimisation on headless stacks is entirely yours to own.

Key Takeaways

  • The Storefront API is public GraphQL for catalog, cart, and checkout handoff — pin version 2026-07 or later.
  • Storefront tokens are safe in browser code; Admin API secrets stay on the server only.
  • Persist cart IDs client-side and redirect to checkoutUrl for payment — do not rebuild checkout.
  • Choose Liquid for speed, Hydrogen for React teams, or raw Storefront API when you need full UI control.
  • Plan SEO, caching, rate limits, and Nepal payment constraints before you commit to headless architecture.
  • Pair Storefront API with Admin API webhooks for order sync, inventory purge, and back-office automation.

People Also Ask

Is the Shopify Storefront API free to use?

Yes. Access is included with your Shopify plan. You pay your normal Shopify subscription and transaction fees. There is no separate API meter for Storefront calls beyond rate limits tied to your plan tier.

Can you use the Storefront API without Hydrogen?

Yes. Hydrogen is optional sugar on top of the same GraphQL endpoint. Any HTTP client in JavaScript, PHP, or mobile can call Storefront API directly with a valid token and versioned endpoint URL.

Does headless Shopify support NPR and local Nepal payments?

Presentment currency and markets are configurable, but local wallets like eSewa are not standard Shopify Checkout methods. Confirm currency support in Admin, then plan custom payment apps or a hybrid domestic checkout if NPR wallets are required.

What is the difference between Storefront API and Storefront MCP?

Storefront API is the stable GraphQL interface for building buyer-facing apps. Newer agent and AI commerce tools may expose higher-level helpers, but production custom frontends still rely on Storefront API mutations and queries documented on shopify.dev.

Ship Your Custom Storefront with the Right API Boundaries

The Shopify Storefront API for custom frontends gives you freedom on UI without giving up Shopify's checkout, inventory, and fulfillment core. Start with a pinned API version, a cart persistence strategy, and a honest read on payment and SEO ownership. Keep Admin API on the server for webhooks and private data.

If you want help scoping a headless build — or deciding whether Liquid is enough — review the portfolio of eCommerce work or reach out through contact us. For full build delivery, see e-commerce development services and related web development options on kokil.com.np.

Frequently Asked Questions

It is Shopify’s customer-facing GraphQL layer for headless storefronts. Your Vue app, Laravel Blade site, or static frontend uses it to fetch catalog data, manage carts, and hand buyers off to Shopify Checkout while Shopify keeps inventory, tax, shipping, and payments.

Yes. It is included with your Shopify plan. You pay normal subscription and transaction fees, not a separate Storefront API meter beyond plan-tier rate limits.

Pin 2026-07 or later. Shopify releases quarterly schema changes, so a fixed version path keeps upgrades deliberate and avoids stale or breaking queries in production.

In Shopify Admin, open Settings, Apps and sales channels, then Develop apps. Create an app, enable Storefront scopes such as unauthenticated_read_product_listings and unauthenticated_write_checkouts, install it, and copy the Storefront access token. Requests go to POST https://{shop}.myshopify.com/api/2026-07/graphql.json with the X-Shopify-Storefront-Access-Token header. For Vite 8.x builds, store the token in frontend env vars like VITE_SHOPIFY_STOREFRONT_TOKEN. A Laravel or Node proxy can hide the token if you want logging and rate-limit control, though direct browser calls are officially supported for Storefront tokens.

They serve different jobs in a headless stack. Storefront API is buyer-facing GraphQL for catalog reads, cart mutations, checkout URLs, and optional customer login data. Admin API manages products, orders, settings, and webhooks from a secure backend. Storefront tokens can live in frontend code. Admin credentials must never be exposed in the browser. In production I pair them the same way I split storefront and admin layers on headless Magento REST builds: Storefront for the shopping UI, Admin API on the server for order sync and back-office automation.

Yes. Hydrogen is optional sugar on the same GraphQL endpoint. Any HTTP client in JavaScript, PHP, or mobile can call Storefront API directly with a valid token and versioned endpoint URL.

Liquid themes ship fastest on the smallest budget but limit layout freedom under Online Store 2.0 constraints. Hydrogen fits React teams committed to Remix, Shopify’s SDK, and Oxygen hosting, with framework lock-in and heavier ops than static sites. Raw Storefront API with Vue, Blade, or a static generator gives full UI control but you own routing, caching, cart edge cases, and SEO. On florist eCommerce work I have seen Liquid plus heavy customisation beat full headless on timeline unless marketing needs a distinct UX, a separate mobile web app, or CMS content outside Shopify.

Start product listings with a collection or search query and request handles, prices, and variant IDs because cart mutations need the variant ID, not the slug alone. For a product page, query by handle and pull title, descriptionHtml, featuredImage, and variant availability. Create carts with cartCreate, add lines with cartLinesAdd, and update quantities with cartLinesUpdate. Pass merchandiseId values like gid://shopify/ProductVariant/1234567890 in the lines array. The mutation returns a cart id and checkoutUrl. Persist the cart ID in localStorage or a cookie so cartLinesAdd and cartLinesUpdate work after navigation. Redirect buyers to checkoutUrl for payment rather than rebuilding checkout yourself.

Storefront API cart state is tied to a cart ID returned by cartCreate or subsequent mutations. If you do not persist that ID in localStorage or a cookie and pass it on later calls, each page load starts a new empty cart. I see this constantly on first headless builds. Fix it before launch by saving the cart ID client-side and reusing it across cartLinesAdd and cartLinesUpdate requests until checkout.

Yes, by design. Storefront access tokens are scoped to unauthenticated buyer actions and cart management. They cannot delete products, refund orders, or perform admin tasks. That boundary is why Shopify supports direct browser calls. Never expose Admin API secrets the same way. If you need private order data or webhook handling, keep Admin API calls on a secure server and use Storefront API only for buyer-facing actions.

Markets and presentment currency are configurable, so confirm whether NPR is enabled in Admin for your store. Payment methods still depend on Shopify Payments availability and third-party gateways. Local wallets such as eSewa and Khalti are not standard Shopify Checkout options. For international card checkout, redirecting to checkoutUrl is the practical path. If domestic NPR wallet checkout is required, plan a hybrid flow with custom payment integrations or an external Laravel cart for domestic-only orders before you promise a fully headless NPR checkout to a Nepal client.

Storefront API uses a calculated query cost bucket, not simple request counts. Deep nested GraphQL queries burn capacity quickly during SSR or large catalog fetches. Flatten product lists, paginate with cursors, and avoid pulling the entire catalog in one query. Log query cost headers in staging using Shopify’s rate limits documentation as your reference. Treat GraphQL responses with an errors array as failed calls even when HTTP status is 200, because partial data plus errors is valid GraphQL and your UI must handle both states.

You do. Headless frontends own URL structure, meta tags, canonical tags, product schema, sitemaps, and Core Web Vitals. Shopify theme SEO defaults disappear when you leave Liquid. That work belongs in architecture, not the week before launch. Cache product pages aggressively at the CDN because catalog data changes less often than cart state, but use shorter TTLs or webhook-driven revalidation if sold-out variants appear due to stale inventory on listing cards. Pair frontend implementation with a technical SEO review if organic search drives revenue.

Do not call Admin API from the browser to patch missing data. That exposes private tokens and violates Shopify policy. Instead, expose the data through metafields with Storefront visibility, or fetch it server-side through Admin API on your Laravel or Node middleware. Use Admin API webhooks such as inventory_levels/update to purge CDN cache keys when live inventory at query time conflicts with aggressive product-list caching. Keep Admin and Storefront concerns separated cleanly in your architecture.

Storefront API is the stable GraphQL interface documented on shopify.dev for building buyer-facing custom frontends with queries and mutations you control. Newer agent and AI commerce tools may expose higher-level helpers under Storefront MCP naming, but production custom storefronts still rely on Storefront API cartCreate, cartLinesAdd, product queries, and checkoutUrl redirects. Treat MCP-style tools as optional conveniences, not a replacement for understanding the underlying GraphQL contract, version pinning, and token scoping before you ship.

Share this article

0 Comments

Leave a comment

Your email is not published. Comments appear once they have been read. Sign in to have your details filled in.

Quick Contact Options
Choose how you want to connect me: