Hygraph
Docs

#Full Tutorial - Build Your First eCommerce Project

This tutorial takes you through a complete Hygraph project: an e-commerce store selling wearables and home goods. By the end, you will have a working schema, real content, a queryable API, and a connected Next.js storefront.

Getting started project previewGetting started project preview

Every decision in this tutorial is one you will face on a real project. The schema choices you make in lessons 1 through 5 determine what you can query in lesson 7 and what your frontend renders in lesson 8.

#Choose your path

Your starting point is a cloned Hygraph project. You can choose your own path through the tutorial.

Option 1: Build from scratch

This clone includes navigation structure and image assets. You will build the schema, content, API configuration, and frontend connection yourself, step by step.

Choose this path if you want to understand how every part of a Hygraph project is constructed and why.

Requirements

Select Option 1

Option 2: Explore a complete project

This clone includes the complete Hygraph project: all models, components, enumerations, content entries, and localized content already built. You will skip straight to querying and frontend connection.

Choose this path if you want to practice API queries, mutations, and frontend integration without building the schema yourself.

Requirements

Select Option 2

#Clone the project

The cloning process is the same for both options.

Clone project screenClone project screen

The project already has a name, but you can give it a new name. You can also optionally add a description, select a region, and click Clone now. Cloning takes a couple of minutes. When it finishes, you land on your project homepage.

#What's already in your project

Your cloned project is fully built. Here is what it contains.

Schema

TypeWhat's included
ModelsProduct, Product category, Blog post, Seller information, Landing page, Navigation
ComponentsRelated Products, Product variant, Clothing, Shoes, Accessories, Decor, Button, Call to Action, Product Grid, Link
EnumerationsClothes size, Shoes size, Wearable items color, Decor items color
Remote sourceHyDemoAPI, a Hygraph-maintained REST API used to fetch product reviews
Remote fieldsReviews field on the Product model; Reviews top-level field on the Query model

Content

TypeWhat's included
Products9 published entries with images, variants, related products, and category assignments
Product categories7 published entries
Landing pagesHomepage and Summer Campaign, both with localized Spanish content
NavigationMain navigation with category and campaign links
Seller information1 published entry
AssetsAll product images with alt text and captions

Your path through the tutorial

  1. Query your content in the API Playground.
  2. Run mutations.
  3. Set up the Next.js frontend starter.
  4. Connect Hygraph to your local frontend.
  5. Configure a preview URL for draft content.
  6. Set up a webhook to trigger frontend deploys on publish.

#Lesson overview

#Lesson 1 — Content models

#LessonWhat you will be able to do
1.1Design your content modelsSketch your model structure and understand how fields, models, and schema relate to each other
1.2Build your content modelsCreate your base models and fields in the Hygraph schema editor

#Lesson 2 — References

#LessonWhat you will be able to do
2.1Configure reference fieldsConnect models to each other using one-to-one, one-to-many, and many-to-many references

#Lesson 3 — Enumerations

#LessonWhat you will be able to do
3.1Configure enumerationsCreate predefined value sets that appear as dropdowns in the content editor

#Lesson 4 — Components

#LessonWhat you will be able to do
4.1Build componentsCreate reusable field sets for product variants, CTAs, related products, and navigation links
4.2Add components to your modelsAttach your components to models as basic and modular component fields

#Lesson 5 — Remote Sources

#LessonWhat you will be able to do
5.1Add a Remote SourceConnect an external REST API to your Hygraph schema
5.2Remote FieldsFetch remote data within the context of a specific model entry
5.3Top-level Remote FieldsFetch remote data outside the context of any model and serve it alongside Hygraph content in a single API call

#Lesson 6 — The Content Editor

#LessonWhat you will be able to do
6.1Create contentCreate and publish products, categories, landing pages, and navigation entries
6.2Localize contentAdd a locale and write localized content for selected fields
6.3Understand content stagesLearn how DRAFT and PUBLISHED content stages affect what the Content API returns and what the frontend displays

#Lesson 7 — The API Playground

#LessonWhat you will be able to do
7.1Exercises: QueriesWrite queries for models, references, components, and remote fields
7.2Exercises: MutationsCreate, update, publish, and delete content entries programmatically

#Lesson 8 — Frontend Connection

#LessonWhat you will be able to do
8.1Set up the frontend starterClone and configure the Next.js e-commerce starter locally
8.2Connect your storefrontConfigure API access permissions, create a PAT, and connect Hygraph to your local frontend
8.3Preview URLAdd a preview button to the content editor sidebar to preview draft content before publishing

#Lesson 9 — Webhooks

#LessonWhat you will be able to do
9.1Configure webhooksSet up a webhook that triggers a frontend rebuild whenever content is published

#What's next

Build from scratch OR Explore a complete project