Overview:
The Hygraph Commerce Starter is a project that allows users to build modern and SEO-ready commerce storefronts using Hygraph, Next.js, Stripe, and Tailwind CSS. It provides an example of how to build a fully-functioning Next.js commerce storefront with features such as a localized product catalogue, pre-rendered catalogue pages, dynamic client-side data fetching, and a localized shopping cart. The project also includes a hosted checkout and payment flow with Stripe Checkout, and uses the Hygraph mutation API with API Routes to create orders on successful checkout. The project supports multiple currencies and requires a Stripe account for usage.
Features:
- Fully localized product catalogue built with Hygraph localization and Next.js
- Pre-rendered catalogue pages via getStaticProps and getStaticPaths
- Dynamic client-side data fetching via SWR
- Localized shopping cart with react-use-cart
- Hosted checkout and payment flow with Stripe Checkout
- Use of the Hygraph mutation API with API Routes to create orders on successful checkout
- Multiple currency support
Installation:
To use the Hygraph Commerce Starter, follow these steps:
- Clone the repository with degit:
npx degit hygraphio/commerce-starter my-commerce-store
- Install project dependencies:
cd my-commerce-store && npm install
- Create a new Hygraph project using the Commerce Starter template:
hygraph init my-commerce-store
- Add a .env file by cloning .env.sample and providing the required variable values
- Create separate Hygraph auth tokens to handle querying and mutating data
- Setup a Stripe webhook for the checkout.session.completed event to enable Hygraph fulfilment via the mutation API
- Configure support for more locales or currencies in hygraph.config.js if required
- Run the project using
npm run dev
Summary:
The Hygraph Commerce Starter is a powerful tool for building modern and SEO-ready commerce storefronts. With features such as a localized product catalogue, pre-rendered catalogue pages, dynamic data fetching, and multiple currency support, it provides a comprehensive solution for building an e-commerce website. By integrating with Stripe Checkout and using the Hygraph mutation API, the project enables a seamless checkout and payment flow. The installation guide provides clear and concise instructions for setting up the project, making it accessible to users of all levels of expertise. Overall, the Hygraph Commerce Starter is a valuable resource for anyone looking to build an online store with advanced features and functionality.