Building High-Performance Online Stores with Shopify Hydrogen and Remix

Rate this content
Bookmark

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

Alexandra Spalato
Alexandra Spalato
104 min
17 Oct, 2023

Comments

Sign in or register to post your comment.

Video Summary and Transcription

The Workshop covered various topics including building a homepage with Hydrogen and Storyblok, querying data using storefront.query and storefront.mutate, building collection indexes and details, adding items to the cart and displaying cart data, connecting Storyblok and adding a development server, setting up environments and creating page routes, using Storyblok and creating page components, personalizing the homepage based on user behavior, integrating Storyblok with Shopify components, and closing remarks.

1. Introduction to Hydrogen and Building the Homepage

Short description:

We are here today to introduce the __ loop behind React. Today, we are working with Spana and Omikasa to hear from them. Hydrogen is built on top of Remix with some packages and an integration of packages. The website we're going to build is the homepage, which is built with hydrogen and Storyblok. It includes a banner, a grid of products, and a single product. Personalization is introduced to display different information based on the customer's behavior. The workshop includes instructions on cloning the repo, creating the.env file, and running npm install.

We are here today to introduce the __ loop behind React. Today, we are working with Spana and Omikasa to hear from them. Before that, please join us in welcoming Omikasa. I wanted to give a talk about hydrogen because I think it's very interesting that Shopify create its own framework and when I begin with it, where we sell our components and then they bought Remix. And so I learned Remix because of hydrogen.

In the beginning, what is funny is I was not attracted to Remix because I'm more frontend and the food stag, etc. And I come from freelancing. Now, I am a dev rel at Storyblok. And what happens, I really fell in love with Remix because it makes everything easier because it's based on the web standards. And so my new talk in conferences is about web standards in Remix. So, it was a double win because I learned hydrogen and I found my favorite framework this way. So, basically, hydrogen is really built on top of Remix with some packages and an integration of packages. Sorry, I have to stop my notifications. The Shopify APIs.

So, let's begin. I'm going to share my screen. To begin, we have this Notion page where I have all the information, all I'm going to say, and all the code is there. So, this is the URL. So, please go there to follow up. It's a short URL, t.li slash hydrogen. Okay? And after that, you will clone this repository so you have the link on the Notion page. And while you're doing that, I'm going to show you the final website that we are going to build.

So this is the website that we're going to build. So this is your homepage. And the homepage is built with hydrogen but also with Storyblok, which is a headless CMS with a visual editor that has extension to integrate commerce in it. So here, first we have a banner, and here we have a grid of products. So these products are pulled from Shopify, but we can see them visually, you know, in the visual editor here. And then we have a single product. And this single product pulls this from Shopify, and this from the CMS, and everything is visual. So I'm going to show you also how this is built.

Now, if we go to find your board here, we are led to the entries for the Shopify connection. So we have a performance board and original board. So if we go to performance boards, here, we see all the collection details with all the Shopify products. So this is 100% Shopify and not Storyblok. And now I can go to my product details. Here I have a Buy Now button and Add to Cart button. So I add the cart, and you can see here's a number of items in my cart. And then if I go to the cart, I can check out. So it's a and I can also remove products. It's a functional, simple e-commerce. I took a free theme from Shopify and to copy the style and take inspiration to make this nice surf website. And now if I come back to the homepage, you can see that this banner has changed. Now it's featuring performance board. And this grid is only a performance board, too. And this is because I have introduced some personalization. I don't know if you heard about personalization, but it's really a high trend now in e-commerce. It means that depending on the behavior of the customer, we are going to display different information. So here, as I have navigated to the performance board, I assume that this user, me, is interested in performance board. So when it comes back to the website, I serve performance boards to drive sales, of course. So I will show you also how this is built in the back office with Storyblok and in the code and how all this works.

So now, I don't know if you have already cloned the repo? And also the notion page? When it's done, you create a.env file. I think there is perhaps a.env example. And here you have all the necessary tokens because I already have a Shopify instance and so you don't have to create it. And you have all the tokens so you will get all the products from there. So please raise your hand if it's not finished. So after that, you clone the repo here. So I will wait five minutes so everybody can do it. And then you run npm install. And after that you create the.env file. And you stay for the moment on the main branch and we are going to progress by branches. Okay, when you are ready, you just run npm run dev or h2dev works also, which is shortcuts. And you should have this. Okay. So I'm going to comment the repo. So to create this, I have create the comment with the comment lines by. So if we go to a hydrogen Shopify. And if we go to the docs, getting started, okay. If we run this command, I let you try this by yourself because last time I did a workshop in four hours and it was taking too much time. But if you run this command, you will have a full featured e-commerce with everything including user registration, search orders, everything you can find and with mock data. So from there you can explore or customize it.

2. Using the Hello World Template and Querying Data

Short description:

In this part, the speaker discusses using the Hello World template and building on top of it. They explain the basic structure of a remix and how to import layouts and wrap outlets. The speaker also introduces the use of storefront.query and storefront.mutate for getting and manipulating data. They mention some challenges with the Hello World template and suggest referring to the documentation. The speaker then guides the audience in creating a query to get the collection index and retrieving the necessary data in the component. They offer assistance and give instructions to try the exercise. The part concludes with a mention of the collections branch.

But in this case, I have used the Hello World template. I think it's another command, so here there is just tutorials that I recommend also if you want to work alone, I learned everything from there and the documentation is really well done. So, okay, let's show this, where is the Hello World command? I just wanted to show... Okay, I don't find a Hello World command now, but it's a basic template and I have built on top of this.

And here what I have already installed because we want to focus on Hydrogen and not on all the basic things. I have installed Tailwind. I also have created the basic things like your footer, okay. A header with just a logo and a menu with just a link to the collections named board and a layout. And so this is a remix. And in remix we have a root file which is the parent root. And so we import the layout here and we wrap our outlet. So the outlet will display the other routes. And so we wrap the layout here. And then we have the index root which is created by default. Here we have the end file. And server.js is our entry point. And this is when you use the Hello world template all this is created for you. So you have this function create store from client and you create the store front with it and it pass all these N variables here. Then it's best to get that context. And so it would be available in the global context of remixes, loaders and actions. So for the ones who don't know remixes it's a full stack framework and loader functions get data from the server and action functions create mutations on the server. So with the storefront, we will be able to make to get data with storefront.query and with storefront.query, we will get the data to create the collections, to create the products, to read the data from the cart and with storefront.mutate, we will perform GraphQL mutations to create the cart operations. Okay, and so everything is full stack, these functions happen on the server and they are the same file from the components where you load the data from the server. So all the components are full stack. So any questions about that? You're muted. I cannot hear you. Well, I'm fine. I'm already happy that I got the environment running, so. Okay. What I wanted to say also, yes, when you install the Hello World template, you don't have that. And so it was a few weeks ago I have to read this talk in Amsterdam. Yes, no, in Croatia, because I have this in Croatia. And what happens, it changed many things. And they had this new content security policy and nothing was working. So this is not the perfect way to do it. There is things in the documentation. So I make it in a quick way like that. Because of that, the image was not working. The scripts neither. So this is something I had on top of the template, just to know what is immediately available and what you have to create. OK, so if your template is working, your repo is working, let's go back to Notion. So now we are going to create the collection of N products. So this is what I was explaining, a storefront query and storefront mutate. We can do this exercise if you want. We can try. So if we go to localhost 3000 and slash GraphQL, we have access to the GraphQL schema. OK? So from there, we want to create a query to get the collection index. So in the collection index, what we have, we have the image from the collection. We have the title and we have a handle that links to the collection details. So we need all that. So we need to create this query. So we can create it in GraphQL. We can search there. Then we need to write it in the root. So I show you the root. Oops. We need to create a root for that. OK. So you can look into the documentation. I will let you have 15 minutes for that. And then we need to write a loader function to query the necessary data. So data from our collection. Then we need to retrieve this data in the component with use loader data hook, which is a hook from Remix to retrieve the data from the server. And then to write a component just to display a collection title. Perhaps it's a bit too much, if you don't know hydrogen, but do you want to try? Do you want the solution immediately? I will give it a try. OK, go! OK. So I'm going to explain because it will be easier. So for that, you go to the branch. To collections. This branch, no one, one collections.

Watch more workshops on topic

Remix Fundamentals
React Summit 2022React Summit 2022
136 min
Remix Fundamentals
Top Content
Featured WorkshopFree
Kent C. Dodds
Kent C. Dodds
Building modern web applications is riddled with complexity And that's only if you bother to deal with the problems
Tired of wiring up onSubmit to backend APIs and making sure your client-side cache stays up-to-date? Wouldn't it be cool to be able to use the global nature of CSS to your benefit, rather than find tools or conventions to avoid or work around it? And how would you like nested layouts with intelligent and performance optimized data management that just works™?
Remix solves some of these problems, and completely eliminates the rest. You don't even have to think about server cache management or global CSS namespace clashes. It's not that Remix has APIs to avoid these problems, they simply don't exist when you're using Remix. Oh, and you don't need that huge complex graphql client when you're using Remix. They've got you covered. Ready to build faster apps faster?
At the end of this workshop, you'll know how to:- Create Remix Routes- Style Remix applications- Load data in Remix loaders- Mutate data with forms and actions
Back to the Roots With Remix
React Summit 2023React Summit 2023
106 min
Back to the Roots With Remix
Featured Workshop
Alex Korzhikov
Pavlik Kiselev
2 authors
The modern web would be different without rich client-side applications supported by powerful frameworks: React, Angular, Vue, Lit, and many others. These frameworks rely on client-side JavaScript, which is their core. However, there are other approaches to rendering. One of them (quite old, by the way) is server-side rendering entirely without JavaScript. Let's find out if this is a good idea and how Remix can help us with it?
Prerequisites- Good understanding of JavaScript or TypeScript- It would help to have experience with React, Redux, Node.js and writing FrontEnd and BackEnd applications- Preinstall Node.js, npm- We prefer to use VSCode, but also cloud IDEs such as codesandbox (other IDEs are also ok)
How to Solve Real-World Problems with Remix
Remix Conf Europe 2022Remix Conf Europe 2022
195 min
How to Solve Real-World Problems with Remix
Featured Workshop
Michael Carter
Michael Carter
- Errors? How to render and log your server and client errorsa - When to return errors vs throwb - Setup logging service like Sentry, LogRocket, and Bugsnag- Forms? How to validate and handle multi-page formsa - Use zod to validate form data in your actionb - Step through multi-page forms without losing data- Stuck? How to patch bugs or missing features in Remix so you can move ona - Use patch-package to quickly fix your Remix installb - Show tool for managing multiple patches and cherry-pick open PRs- Users? How to handle multi-tenant apps with Prismaa - Determine tenant by host or by userb - Multiple database or single database/multiple schemasc - Ensures tenant data always separate from others
Build and Launch a personal blog using Remix and Vercel
Remix Conf Europe 2022Remix Conf Europe 2022
156 min
Build and Launch a personal blog using Remix and Vercel
Featured Workshop
Robert Pop
Robert Pop
In this workshop we will learn how to build a personal blog from scratch using Remix, TailwindCSS. The blog will be hosted on Vercel and all the content will be dynamically served from a separate GitHub repository. We will be using HTTP Caching for the blog posts.
What we want to achieve at the end of the workshop is to have a list of our blog posts displayed on the deployed version of the website, the ability to filter them and to read them individually.
Table of contents: - Setup a Remix Project with a predefined stack- Install additional dependencies- Read content from GiHub- Display Content from GitHub- Parse the content and load it within our app using mdx-bundler- Create separate blog post page to have them displayed standalone- Add filters on the initial list of blog posts
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

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

Building Better Websites with Remix
React Summit Remote Edition 2021React Summit Remote Edition 2021
33 min
Building Better Websites with Remix
Top Content
Remix is a new web framework from the creators of React Router that helps you build better, faster websites through a solid understanding of web fundamentals. Remix takes care of the heavy lifting like server rendering, code splitting, prefetching, and navigation and leaves you with the fun part: building something awesome!
Don't Solve Problems, Eliminate Them
React Advanced Conference 2021React Advanced Conference 2021
39 min
Don't Solve Problems, Eliminate Them
Top Content
Humans are natural problem solvers and we're good enough at it that we've survived over the centuries and become the dominant species of the planet. Because we're so good at it, we sometimes become problem seekers too–looking for problems we can solve. Those who most successfully accomplish their goals are the problem eliminators. Let's talk about the distinction between solving and eliminating problems with examples from inside and outside the coding world.
Scaling Up with Remix and Micro Frontends
Remix Conf Europe 2022Remix Conf Europe 2022
23 min
Scaling Up with Remix and Micro Frontends
Top Content
Do you have a large product built by many teams? Are you struggling to release often? Did your frontend turn into a massive unmaintainable monolith? If, like me, you’ve answered yes to any of those questions, this talk is for you! I’ll show you exactly how you can build a micro frontend architecture with Remix to solve those challenges.
Full Stack Components
Remix Conf Europe 2022Remix Conf Europe 2022
37 min
Full Stack Components
Top Content
Remix is a web framework that gives you the simple mental model of a Multi-Page App (MPA) but the power and capabilities of a Single-Page App (SPA). One of the big challenges of SPAs is network management resulting in a great deal of indirection and buggy code. This is especially noticeable in application state which Remix completely eliminates, but it's also an issue in individual components that communicate with a single-purpose backend endpoint (like a combobox search for example).
In this talk, Kent will demonstrate how Remix enables you to build complex UI components that are connected to a backend in the simplest and most powerful way you've ever seen. Leaving you time to chill with your family or whatever else you do for fun.
Remix Flat Routes – An Evolution in Routing
Remix Conf Europe 2022Remix Conf Europe 2022
16 min
Remix Flat Routes – An Evolution in Routing
Top Content
This talk introduces the new Flat Routes convention that will most likely be the default in a future version of Remix. It simplifies the existing convention as well as gives you new capabilities.
Remix Architecture Patterns
Remix Conf Europe 2022Remix Conf Europe 2022
23 min
Remix Architecture Patterns
Top Content
Remix provides amazing flexibility and can be deployed anywhere where JavaScript is running. But how does Remix fit into the bigger application landscape of an organization? Remix provides great utility, but how to best take advantage of it? What things should be handled inside of Remix, and what things are better off done elsewhere? Should we use the express adapter to add a WebSocket server or should that be a standalone microservice? How will enterprise organizations integrate Remix into their current stacks? Let’s talk architecture patterns! In this talk, I want to share my thoughts about how to best integrate Remix into a greater (enterprise) stack.