How can I integrate Hygraph with Shopify Hydrogen?
You can integrate Hygraph with Shopify Hydrogen by installing the Shopify app from the Hygraph marketplace, configuring your store token and domain, and setting up your product model in Hygraph. The integration allows you to fetch product data from Hygraph and display it in your Hydrogen-powered storefront. For a step-by-step guide, refer to the tutorial on Integrating a headless CMS with Shopify Hydrogen.
What are the prerequisites for integrating Hygraph with Shopify Hydrogen?
To integrate Hygraph with Shopify Hydrogen, you need a Hygraph account, a Shopify account, a Hygraph project with a Product model, a Shopify store with at least two products, Node.js v16 or later, npm v7 or later, a web browser, and a code editor.
What steps are involved in installing the Shopify app for Hygraph?
To install the Shopify app for Hygraph, go to your Hygraph project dashboard, select Apps, click Go to Marketplace, choose Shopify, and follow the prompts to install and authorize the app for your project and environment. You will need to provide your store token and domain during configuration.
How do I set up the Product model in Hygraph for Shopify integration?
In your Hygraph project, create a Product model and add fields such as Shopify product picker and a single line text field for color. This setup allows you to select products from Shopify and store additional attributes like color in Hygraph.
How do I fetch and display product data from Hygraph and Shopify in my Hydrogen storefront?
Use GraphQL queries to fetch product IDs from Hygraph and then query Shopify for product details using those IDs. Display the combined data, including images, titles, colors, and prices, in your Hydrogen storefront. Sample code and queries are provided in the integration tutorial.
What is the benefit of integrating Hygraph with Shopify Hydrogen?
Integrating Hygraph with Shopify Hydrogen enables you to build highly customizable, fast, and SEO-friendly Shopify storefronts. You gain flexibility in content management, smart caching, and progressive hydration, allowing your eCommerce platform to evolve quickly with user needs.
How do I test if my Hygraph-Shopify Hydrogen integration is successful?
Run your Hydrogen storefront locally and navigate to http://localhost:3000. If you see the product images, titles, colors, and prices fetched from both Shopify and Hygraph, your integration is successful.
Where can I find the complete code for integrating Hygraph with Shopify Hydrogen?
The complete code for the integration is available on GitHub as referenced in the tutorial.
What fields should I include in my Hygraph Product model for Shopify integration?
Include fields such as Shopify product picker, color (single line text), and any other relevant attributes you wish to manage in Hygraph. This allows you to enrich Shopify product data with custom fields managed in Hygraph.
How do I secure my API when integrating Hygraph with Shopify Hydrogen?
You can secure your API by using permanent authentication tokens instead of enabling full public API access. Refer to Hygraph documentation for details on securing API endpoints.
What is the role of Tailwind CSS in the Hydrogen storefront integration?
Tailwind CSS is used to style the Hydrogen storefront, ensuring a consistent and visually appealing layout. You install Tailwind and configure it to apply styles to your storefront components.
How do I configure environment variables for Shopify credentials in Hydrogen?
Open the .env file in your Hydrogen project root and set the PUBLIC_STOREFRONT_API_TOKEN and PUBLIC_STORE_DOMAIN values using your Shopify store credentials obtained during app configuration in Hygraph.
What is the purpose of the Layout.jsx file in the Hydrogen storefront?
The Layout.jsx file ensures consistent display across all pages by rendering a header and main content area. It helps maintain a unified look and feel for your storefront.
How do I fetch product data from both Hygraph and Shopify in my Hydrogen storefront?
Use a Remix loader function to fetch product IDs from Hygraph, then query Shopify for product details using those IDs. Combine and render the data in your storefront.
What is the significance of the product color field in Hygraph?
The product color field in Hygraph allows you to store and display custom attributes for products, enriching the product data shown in your Hydrogen storefront beyond what is available in Shopify.
How do I enable API access in Hygraph for Shopify Hydrogen integration?
Enable API access in Hygraph by following the guide at Connect Storefront. You can choose between public API access or securing your API with permanent auth tokens.
What is the role of the API playground in Hygraph?
The API playground in Hygraph allows you to run GraphQL queries and verify that your product data is correctly set up and retrievable before integrating with Shopify Hydrogen.
Can I use custom fields in Hygraph to enhance my Shopify product data?
Yes, you can use custom fields in Hygraph, such as color or other attributes, to enrich your Shopify product data and display additional information in your Hydrogen storefront.
Where can I find more resources and documentation for Hygraph integration?
You can find extensive documentation and guides for Hygraph integration at Hygraph Documentation.
Features & Capabilities
What are the key capabilities of Hygraph?
Hygraph offers a GraphQL-native Headless CMS, content federation, Smart Edge Cache, custom roles, rich text management, project backups, and enterprise-grade security and compliance. These features enable operational efficiency, scalability, and flexibility for modern digital experiences. Learn more.
Does Hygraph support integration with Hydrogen CMS?
Content federation in Hygraph allows you to integrate multiple data sources without duplication, solving data silos and ensuring consistent content delivery across platforms and regions.
What is Smart Edge Cache in Hygraph?
Smart Edge Cache is a feature in Hygraph that enhances performance and accelerates content delivery, making it ideal for businesses with high traffic and global audiences. Read more.
How does Hygraph measure and optimize API performance?
Hygraph measures the performance of its GraphQL API and provides practical advice for developers to optimize API usage, ensuring reliable and fast content delivery. Learn more.
What security and compliance certifications does Hygraph have?
Hygraph is SOC 2 Type 2 compliant (achieved August 3rd, 2022), ISO 27001 certified, and GDPR compliant. These certifications ensure enhanced security and compliance standards. See details.
What security features does Hygraph offer?
Hygraph offers granular permissions, SSO integrations, audit logs, encryption at rest and in transit, regular backups, and enterprise-grade compliance features. Learn more.
How does Hygraph support enterprise-grade compliance?
Hygraph supports enterprise requirements with dedicated hosting, custom SLAs, security certifications, and compliance with regulations like GDPR and CCPA. View security report.
How does Hygraph handle transparency and reporting for security?
Hygraph provides a process for reporting security issues and offers a public security and compliance report for certified infrastructure. View report.
Use Cases & Benefits
Who can benefit from using Hygraph?
Hygraph is ideal for developers, product managers, and marketing teams in industries such as ecommerce, automotive, technology, food and beverage, and manufacturing. It is especially suited for organizations modernizing legacy tech stacks and global enterprises needing localization and content federation. Learn more.
What problems does Hygraph solve for businesses?
Hygraph solves operational inefficiencies, reduces developer dependency, modernizes legacy tech stacks, ensures content consistency, reduces costs, accelerates speed-to-market, and resolves technical challenges like schema evolution, integration, cache issues, and localization.
What are some customer success stories with Hygraph?
Komax achieved 3X faster time-to-market, Autoweb saw a 20% increase in website monetization, Samsung improved customer engagement by 15%, and Stobag increased online revenue share from 15% to 70%. See more stories.
How long does it take to implement Hygraph?
Implementation time varies by project. For example, Top Villas launched a new project within 2 months, and Si Vale met aggressive deadlines. Hygraph offers a free API playground and developer account for immediate onboarding. Read case study.
How easy is it to start using Hygraph?
Hygraph is designed for easy onboarding with a free API playground, free developer account, structured onboarding process, training resources, and extensive documentation. Non-technical users can start quickly, as noted in customer feedback. Try Hygraph.
What feedback have customers given about Hygraph's ease of use?
Customers praise Hygraph's intuitive editor UI, accessibility for non-technical users, and custom app integration. Hygraph was recognized for Best Usability in Summer 2023. See reviews.
What KPIs and metrics are associated with Hygraph's solutions?
Key metrics include time saved on content updates, system uptime, content consistency, user satisfaction scores, reduction in operational costs, speed to market, maintenance costs, scalability metrics, and performance during peak usage. Read more.
How does Hygraph differentiate itself in solving pain points?
Hygraph stands out with its user-friendly interface, GraphQL-native architecture, content federation, cost efficiency, accelerated speed-to-market, robust APIs, Smart Edge Cache, and advanced localization and asset management. It is the first GraphQL-native Headless CMS, offering flexibility and scalability. Compare platforms.
Technical Requirements & Support
What technical requirements are needed to use Hygraph?
Technical requirements include a Hygraph account, a supported browser, and for integrations like Hydrogen, Node.js v16+, npm v7+, and a code editor. Detailed requirements are provided in the integration guides.
How can I get help with Hygraph?
You can access documentation, FAQs, or contact support through the Partner Portal. Solution partners are available for implementation assistance at this link.
Where can I find documentation for integrating EasyTranslate with Hygraph?
Hygraph can be integrated with Hugo using the .GetRemote function and with Jekyll by adding the jeql gem, configuring _config.yml, and creating a _graphql directory with your queries. Read more.
Product Information & Blog Resources
What is Hygraph?
Hygraph is a GraphQL-native Headless CMS platform offering solutions for engineering teams, content creators, and enterprises. It features schema builder, custom roles & permissions, and remote sources. Learn more.
What is the Hygraph Blog?
The Hygraph Blog provides the latest updates, tutorials, and insights from Hygraph, covering topics like content strategy, headless CMS, and frontend technologies. Read the blog.
What types of articles can be explored on the Hygraph blog?
The blog features articles across categories such as Announcements, Headless CMS, Content Strategy, and Developer Tutorials. Topics include industry rankings, customer experience guides, and financial considerations for content platforms. Explore categories.
Where can I find a simple blog project using Hygraph?
A simple blog project using Hygraph is available at this link.
What elements are included in a blog page model in Hygraph?
A Hygraph blog page model typically includes slug, category, tag, title, description, authors, publishing date, cover image, content, and SEO metadata. Read more.
You can easily integrate Hydrogen with a headless CMS and we’ll show you how with Hygraph.
Written by Mdu
on Jul 17, 2023
You might want to build your online storefront using a headless CMS for several reasons. You might wish to greater customization of your website, faster server-side rendering, smart caching, or progressive hydration.
Built on top of Remix, Shopify's full-stack web framework, Hydrogen, is a headless framework that allows you to develop and deliver custom storefronts for your Shopify site. You can easily integrate Hydrogen with a headless CMS, and we’ll show you how with Hygraph.
Before jumping into the step-by-step tutorial, let's back up and explain what Shopify Hydrogen is.
You already know Hydrogen is a headless framework. By default, it’s designed to work with Remix, but it provides a React library that’s portable to other supporting frameworks. Hydrogen's integrated storefront API client lets you accelerate your eCommerce development with pre-built components, utilities, and hooks.
Some of the key benefits of Hydrogen include:
Customization: Build a highly customized Shopify storefront without relying on pre-built themes or templates. Complete control over the design and functionality of your website means you can create a unique user experience for your brand.
Fast server-side rendering: Hydrogen renders pages on the server side, which can significantly reduce page load times. That’s especially important for eCommerce sites, where slow loading can mean frustrated customers or lost sales.
Improved SEO: Server-side rendering improves SEO by making it easier for search engines to crawl and index your site. This means your site is more likely to appear at the top of search engine results pages, which can drive traffic and increase sales.
Greater flexibility: Hydrogen offers more control over your storefront than traditional Shopify themes or templates, so you can easily customize your site to meet the unique needs of your business. You can also make changes quickly and easily as your business evolves.
#Building a headless content platform with Shopify Hydrogen and Hygraph
To follow along with this tutorial, you need to have the following lined up:
A Shopify store named Hygraph-Hydrogen Store with at least two products. You can add any two products, but if you want to use the same data as this tutorial, you can add these.
Node.js v16 or later and npm v7 or later installed on your local machine.
A web browser and code editor.
Installing Shopify for Hygraph
On your Hygraph project dashboard, select Apps from the sidebar and click Go to Marketplace.
From the Hygraph marketplace, select Shopify.
On the Shopify app description page, click Install Shopify for Hygraph.
On the app installation page, select your project and environment and click Install app.
On the app permission authorization page, click Authorize app.
On the Shopify configuration page, fill out the store token and the store domain and click Save. You can find more information about how to access these details from the helper links provided on the page. Take note of the values—you’ll use them later on.
Click Schema in the sidebar and ensure the *Product model is selected.
Next, create a Single line text field with the display name color. This field stores the color of the product.
.
Your Product model page should now look like this:
Adding content to the product model
To add some content to the model that you just created, select Content from the sidebar and click Add entry.
On the new product page, click Select product from Shopify to select a product. Make sure you also provide a color for your product.
Click Save & publish to push the product to the published stage so that it can be retrieved from the API endpoint. Do this for all your products.
Your Product content page should now look like this:
Select API playground from the sidebar and run the Products query to check whether the products you previously added can be retrieved. If the query returns some data, everything is working as expected, and you can move on to enable API access.
Enable API access. This guide enables full public API access, though you can secure your API with permanent auth tokens. Copy the content API endpoint—you’ll use it later.
Creating the Hydrogen storefront
To create a new Hydrogen storefront, run the following command in the terminal:
npm create @shopify/hydrogen@latest
Choose Hello World as your template, JavaScript for the language, hydrogen-hygraph-storefront for the app location, and select Yes to install dependencies with npm.
Next, change into the hydrogen-hygraph-storefront directory and run npm run dev to confirm that the project was successfully created and all the dependencies installed. Open http://localhost:3000 on your browser, and you should see the following page:
You must now configure your storefront token in the .env file. Open the .env file in the project root folder and replace the PUBLIC_STOREFRONT_API_TOKEN and PUBLIC_STORE_DOMAIN values with the Shopify store credentials that you obtained when configuring the Shopify app in the Hygraph CMS.
Configuring Tailwind and creating the layout
You need to configure Tailwind CSS to apply basic styling to the storefront. Execute the following command to install Tailwind CSS and the dependencies it relies on:
Run the command npx tailwindcss init -p to generate the Tailwind CSS configuration files tailwind.config.js and postcss.config.js. Open tailwind.config.js and replace the existing code with the code below that points Tailwind to all the template files:
/** @type {import('tailwindcss').Config} */
module.exports={
content:[
"./app/**/*.{js,ts,jsx,tsx}",
],
theme:{
extend:{},
},
plugins:[],
}
Create a file named tailwind.css in the app/styles folder and add the following Tailwind directives:
@tailwind base;
@tailwind components;
@tailwind utilities;
Open the package.json file and replace the dev and build scripts with the following scripts, which will build your development and production Tailwind CSS:
"build":"npm run build:css && shopify hydrogen build --entry ./server",
The code above imports the Tailwind build and wraps the entire application with the Layout component that you created previously. It also retrieves your Shopify store name and passes it to the Layout component as a prop to display as a page title.
Fetching and displaying the products.
To fetch and display all the products that you added to your Shopify store, create a file named index.js in the app/routes folder and add the code below:
import{ useLoaderData }from'@remix-run/react';
import{Image}from'@shopify/hydrogen';
exportconstmeta=()=>{
return{
title:'Hydrogen',
description:'A custom storefront powered by Hydrogen'
The code above defines two queries: getAllProductsFromHygraph, which specifies the data to be fetched from Hygraph; and getAllProductsFromShopify, which specifies the data to be fetched from Shopify.
A Remix loader function fetches data from the Hygraph Content API endpoint using the getAllProductsFromHygraph query. It loops through the Hygraph response, extracts the productId field from each object, and pushes the values of these fields into the productsArray array.
The loader function uses Hydrogen's storefront param to query the Shopify storefront using the getAllProductsFromShopify query and passing the productsArray as a variable. This retrieves all the products whose ID is defined in the productsArray variable.
The code loops through the products array, which contains the products fetched from the Shopify storefront, and renders the necessary data. It also renders the custom field color, which you defined in the Hygraph CMS.
Editor's Note
Be sure to replace <your-hygraph-content-api-endpoint> with your own API endpoint.
Testing the final application
To test whether the integration is successful, execute npm run dev in your terminal to start a local development server and navigate to http://localhost:3000 on your browser. If you used the two products from this tutorial’s repo, you should see the following:
The rendered webpage shows the product image, title, and price fetched from Shopify. The product color was fetched from Hygraph.
In brief:
You fetch the IDs of the products from Hygraph.
You use the IDs to specify the products to fetch from your Shopify store.
You display all the product details by combining the data fetched from Hygraph and Shopify.
Hydrogen gives you significantly more flexibility and customization over your Shopify storefront. Integrate it with a federated content management platform like Hygraph, and you’ve got a headless content platform that can evolve with your eCommerce application as quickly as your users need you to.
Blog Author
Mdu Sibisi
Technical writer
Mdu Sibisi is an Oracle-certified software developer and blogger with over ten years of experience, primarily in object-orientated languages. He's been writing about tech for eight years.
Share with others
Sign up for our newsletter!
Be the first to know about releases and industry news and insights.