Building custom storefronts on Shopify with Hydrogen

Rate this content
Bookmark

Get hands-on with Hydrogen, a React-based framework powered by Shopify. In this workshop, we'll explore the framework and get a custom storefront up and running quickly. You'll learn how (and when) to leverage React Server Components and caching mechanisms to build fast, dynamic, custom storefronts.

Abe Haskins
Abe Haskins
Megan Majewski
Megan Majewski
71 min
01 Jul, 2022

Comments

Sign in or register to post your comment.

Video Summary and Transcription

This workshop introduces Shopify's Hydrogen, a React-based framework for building headless storefronts. Hydrogen offers fast client-side rendering, flexible caching, and a simplified development process. It uses file-based routing and allows for dynamic routes. The workshop covers querying the Storefront API with GraphiQL, using GraphQL queries in Hydrogen, and accessing product details. It also demonstrates the use of the product options provider, the cart provider, and the add to cart button. Hydrogen is recommended for larger merchants and provides scalability and flexibility for building e-commerce stores.

1. Introduction to Shopify's Hydrogen

Short description:

Welcome to the workshop on building headless storefronts using Shopify's Hydrogen. I'm Megan, a dev advocate at Shopify, and I'm excited to share this latest workshop with you. I'm Abe, another developer advocate, here to support Megan and answer any questions you may have. Let's get started!

So, let's dive right in. All right, cool. Well, welcome, everybody. As the title slide says, and I'm sure you know since you signed up for this workshop, we're gonna be going over building headless storefronts using Shopify's new tool called Hydrogen. We'll kind of get some hands-on coding today, but I'm super excited to be sharing with you this workshop because it's kind of the latest from Shopify and React.

I'm Megan. You can find me on Discord, Twitter, YouTube. I'm a dev advocate here at Shopify. So, I'm pretty active in the community. So, feel free to say, hi, if you kind of see me around. So, part of my team work focuses on kind of bringing you guys workshops like this one and highlighting some of the other cool things that Shopify is doing, as well as kind of hearing from you guys and understanding what you're interested in Shopify doing and seeing all the cool stuff that the community is building.

And I'm Abe. I'm also a developer advocate at Shopify. My job is mostly to let Megan do her job and then show up to actually give the talk and act like I did any of the work to prepare for it. Similarly, I flirt around on various socials. I do have a Twitter account and things like that, but I wouldn't recommend following me because I don't tweet anything interesting. But I'm around. You'll see me pop up in all sorts of different Shopify related resources. And, of course, you can always shoot me an email if you have any specific questions or thoughts either about the workshop or anything Shopify developer related in general. Always happy to chat or route your question to someone who has a better answer than I do.

2. Introduction to Hydrogen

Short description:

Today we'll be using Hydrogen to build a product page. Hydrogen is a framework that Shopify recently released, allowing you to put a head on top of the headless APIs. It's a React-based framework with utilities to simplify building an e-commerce store. Hydrogen powers personalized, dynamic e-commerce sites using React server components, streaming server-side rendering, and flexible cache policies.

Cool. So today we'll be using Hydrogen to build a product page. What you'll learn is some major features that Hydrogen has developed to help you ship and build fast. And by the end of the workshop, we'll get hands on, we'll do some coding. You'll check out some of the tools that Shopify has developed to help you rapidly build a custom storefront. And hopefully by the end, there'll be some time for Q&A. But if you have any questions, feel free to put them in the chat as we go through and we'll try to tag team and get through them there as well.

So let's get into it. Abe, you want to kick us off? Yeah. So, for anyone who's not familiar, Hydrogen is a framework that Shopify recently released. Basically, what it is, is a way for you to put a head on top of the headless APIs that Shopify offers. When a lot of people see Shopify, they think of people who go into our public interface and design a shop using the drag and drop interface and kind of pick a theme from the store, things like that, kind of just customizing off the shelf e-commerce experiences. But Hydrogen is a very different approach. We offer all these APIs that basically let you do everything that we can do with your store, you can do through an API. And then Hydrogen lets you build any UI you want on top of that. So we're going to get into it a bit here, but the important parts are, it's a React based framework. So it'll be familiar to anyone who's worked with React, with a bunch of cool helpers and utilities to help building a Shopify powered store. E-commerce in general is like super hard and you'll see here that, like, we've tried to pull together a bunch of utilities and helpers and things that are kind of like the common use cases for building a store. You know, you need like a cart, you need product pages, you need all these different little components, like different versions or variants that we'll talk about. So, you know, if you have a product that has different colors or things like that, all of this is pretty generic to e-commerce. And this is kind of the problem Hydrogen is hoping to solve. Simplify the problem, make building an e-commerce store easier, but still give you the absolute maximum amount of power you could need to do whatever crazy type of store you want to do.

Yeah, so as I was just saying, Hydrogen is built to power personalized, dynamic e-commerce sites. And to do this, we have three separate strategies that kind of work together. They are React server components, streaming, server-side rendering, which for me is a mouthful. So if I start slurring that, I apologize. That's what I mean. Streaming, server-side rendering and the final one is flexible cache policies. Let's talk details about each of these. So React server components. Maybe you heard about this with React 18. It's prominently featured in Hydrogen and it's like kind of the new up and coming React topic. It's not the same as server-side rendering. I know it's like a little bit confusing. I actually thought they were the same thing for a while until I started digging into Hydrogen and how we make use of it. But server components allow both the server and the client, meaning the browser, to collaborate together when rendering your React application. So if you think about your typical React application, this is like an element tree of React components that are including more React components, and it's all kind of loaded and done on the browser side. React server components make it possible for some of those components in the tree instead to be rendered by the server. And then you can push off some of the work to the server side and still have some client rendered components by the browser. This has a couple of advantages. The first one is, of course, your server has more direct access to your data sources, so things like your database, GraphQL, endpoints, or even your file system, things like that. The server can directly fetch the data that you need and it doesn't have to go through an API endpoint like your client side would normally have to. So this makes your app faster and also more secure because you don't have to go through that API layer. And if you have a lot of heavy code modules, so maybe, for example, you have like an expensive date formatting library or something like that, you can use that on your server component. So that means the library that you're using that might be a little big and bloated stays on your server, doesn't ever need to be transferred to your client. So you reduce your overall bundle size and also help the speediness of the loading. One thing to understand while we're kind of talking about this topic is server components, like we said, can fetch data and access the system or maybe your file system, but you cannot store state or have any context in these components. So if you need access to a state or context or anything like that, that's when you would have to bring in a client component because that work is obviously done on the browser. This next topic that we've included, the streaming server side, rendering server side, rendering is not itself a new component, but in react18. There's a new SSR API powered by suspense, and this really kind of unlocks a lot of cool features for server side rendering, so it eliminates data fetching waterfalls.

QnA

Watch more workshops on topic

Next.js 13: Data Fetching Strategies
React Day Berlin 2022React Day Berlin 2022
53 min
Next.js 13: Data Fetching Strategies
Top Content
WorkshopFree
Alice De Mauro
Alice De Mauro
- Introduction- Prerequisites for the workshop- Fetching strategies: fundamentals- Fetching strategies – hands-on: fetch API, cache (static VS dynamic), revalidate, suspense (parallel data fetching)- Test your build and serve it on Vercel- Future: Server components VS Client components- Workshop easter egg (unrelated to the topic, calling out accessibility)- Wrapping up
Building a Shopify App with React & Node
React Summit Remote Edition 2021React Summit Remote Edition 2021
87 min
Building a Shopify App with React & Node
Top Content
WorkshopFree
Jennifer Gray
Hanna Chen
2 authors
Shopify merchants have a diverse set of needs, and developers have a unique opportunity to meet those needs building apps. Building an app can be tough work but Shopify has created a set of tools and resources to help you build out a seamless app experience as quickly as possible. Get hands on experience building an embedded Shopify app using the Shopify App CLI, Polaris and Shopify App Bridge.We’ll show you how to create an app that accesses information from a development store and can run in your local environment.
Create a Visually Editable Next.js Website Using React Bricks, With Blog and E-commerce
React Summit 2023React Summit 2023
139 min
Create a Visually Editable Next.js Website Using React Bricks, With Blog and E-commerce
WorkshopFree
Matteo Frana
Matteo Frana
- React Bricks: why we built it, what it is and how it works- Create a free account- Create a new project with Next.js and Tailwind- Explore the directory structure- Anatomy of a Brick- Create a new Brick (Text-Image)- Add a title and description with RichText visual editing- Add an Image with visual editing- Add Sidebar controls to edit props (padding and image side)- Nesting Bricks using the Repeater component- Create an Image gallery brick- Publish on Netlify or Vercel- Page Types and Custom fields- Access Page meta values- Internationalization- How to reuse content across pages: Stories and Embeds- How to create an E-commerce with Products’ data from an external database and landing pages created visually in React Bricks- Advanced enterprise features: flexible permissions, locked structure, custom visual components
React Server Components Unleashed: A Deep Dive into Next-Gen Web Development
React Advanced Conference 2023React Advanced Conference 2023
153 min
React Server Components Unleashed: A Deep Dive into Next-Gen Web Development
Workshop
Maurice de Beijer
Maurice de Beijer
Get ready to supercharge your web development skills with React Server Components! In this immersive, 3-hour workshop, we'll unlock the full potential of this revolutionary technology and explore how it's transforming the way developers build lightning-fast, efficient web applications.
Join us as we delve into the exciting world of React Server Components, which seamlessly blend server-side rendering with client-side interactivity for unparalleled performance and user experience. You'll gain hands-on experience through practical exercises, real-world examples, and expert guidance on how to harness the power of Server Components in your own projects.
Throughout the workshop, we'll cover essential topics, including:
- Understanding the differences between Server and Client Components- Implementing Server Components to optimize data fetching and reduce JavaScript bundle size- Integrating Server and Client Components for a seamless user experience- Strategies for effectively passing data between components and managing state- Tips and best practices for maximizing the performance benefits of React Server Components
Workshop level: 
No matter your current level of React expertise, this workshop will equip you with the knowledge and tools to take your web development game to new heights. Don't miss this opportunity to stay ahead of the curve and master the cutting-edge technology that's changing the face of web development. Sign up now and unleash the full power of React Server Components!
Building High-Performance Online Stores with Shopify Hydrogen and Remix
React Advanced Conference 2023React Advanced Conference 2023
104 min
Building High-Performance Online Stores with Shopify Hydrogen and Remix
WorkshopFree
Alexandra Spalato
Alexandra Spalato
I. Introduction- Overview of Shopify Hydrogen and Remix- Importance of headless e-commerce and its impact on the industry
II. Setting up Shopify Hydrogen- Installing and setting up Hydrogen with Remix- Setting up the project structure and components
III. Creating Collections and Products- Creating collections and products using Hydrogen’s React components- Implementing a Shopping Cart- Building a shopping cart using Hydrogen’s built-in components
VI. Building the home page with Storyblok- Cloning the space and explaining how it works- Implementing Storyblok in the repo- Creating the Blok components- Creating the Shopify components- Implementing personalisation
Build a Custom Storefront on Shopify with Hydrogen
React Advanced Conference 2021React Advanced Conference 2021
170 min
Build a Custom Storefront on Shopify with Hydrogen
Workshop
Matt Seccafien
Cathryn Griffiths
2 authors
Hydrogen is an opinionated React framework and SDK for building fast, custom storefronts powered Shopify. Hydrogen embraces React Server Components and makes use of Vite and Tailwind CSS. In this workshop participants will get a first look at Hydrogen, learn how and when to use it, all while building a fully functional custom storefront with the Hydrogen team themselves.

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

Simplifying Server Components
React Advanced Conference 2023React Advanced Conference 2023
27 min
Simplifying Server Components
Top Content
Server Components are arguably the biggest change to React since its initial release but many of us in the community have struggled to get a handle on them. In this talk we'll try to break down the different moving parts so that you have a good understanding of what's going on under the hood, and explore the line between React and the frameworks that are built upon it.
Exploring React Server Component Fundamentals
React Day Berlin 2023React Day Berlin 2023
21 min
Exploring React Server Component Fundamentals
Top Content
I've been developing a minimalistic framework for React Server Components (RSC). This talk will share my journey to deeply understand RSC from a technical perspective. I'll demonstrate how RSC features operate at a low level and provide insights into what RSC offers at its core. By the end, you should have a stronger mental model of React Server Components fundamentals.
Server Components: The Epic Tale of Rendering UX
React Summit 2023React Summit 2023
26 min
Server Components: The Epic Tale of Rendering UX
Server components, introduced in React v18 end these shortcomings, enabling rendering React components fully on the server, into an intermediate abstraction format without needing to add to the JavaScript bundle. This talk aims to cover the following points:1. A fun story of how we needed CSR and how SSR started to take its place2. What are server components and what benefits did they bring like 0 javascript bundle size3. Demo of a simple app using client-side rendering, SSR, and server components and analyzing the performance gains and understanding when to use what4. My take on how rendering UI will change with this approach
A Practical Guide for Migrating to Server Components
React Advanced Conference 2023React Advanced Conference 2023
28 min
A Practical Guide for Migrating to Server Components
Server Components are the hot new thing, but so far much of the discourse around them has been abstract. Let's change that. This talk will focus on the practical side of things, providing a roadmap to navigate the migration journey. Starting from an app using the older Next.js pages router and React Query, we’ll break this journey down into a set of actionable, incremental steps, stopping only when we have something shippable that’s clearly superior to what we began with. We’ll also discuss next steps and strategies for gradually embracing more aspects of this transformative paradigm.
Batteries Included Reimagined - The Revival of GraphQL Yoga
GraphQL Galaxy 2021GraphQL Galaxy 2021
33 min
Batteries Included Reimagined - The Revival of GraphQL Yoga
The Guild has recently released Envelop - a new, modern GraphQL Server Framework and plugin system. In this talk I’ll share a brief overview of Envelop and why you should probably upgrade your existing GraphQL server to it.
React Server Components
React Day Berlin 2023React Day Berlin 2023
27 min
React Server Components
React Server Components are a newer way of working with React that is widely adopted in frameworks like Next.js. In this talk, we will look under the surface of how they work and are executed on the server side, and how they fit with server rendering and traditional React apps.