Skip to content

Commit

Permalink
copy hydrogen-2 example from vercel/vercel (#1016)
Browse files Browse the repository at this point in the history
  • Loading branch information
erikareads authored Jan 13, 2025
1 parent 488603d commit f3a11a2
Show file tree
Hide file tree
Showing 59 changed files with 20,900 additions and 0 deletions.
4 changes: 4 additions & 0 deletions framework-boilerplates/hydrogen-2/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# The variables added in this file are only available locally in MiniOxygen

SESSION_SECRET="foobar"
PUBLIC_STORE_DOMAIN="mock.shop"
5 changes: 5 additions & 0 deletions framework-boilerplates/hydrogen-2/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
build
node_modules
bin
*.d.ts
dist
18 changes: 18 additions & 0 deletions framework-boilerplates/hydrogen-2/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* @type {import("@types/eslint").Linter.BaseConfig}
*/
module.exports = {
extends: [
'@remix-run/eslint-config',
'plugin:hydrogen/recommended',
'plugin:hydrogen/typescript',
],
rules: {
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/naming-convention': 'off',
'hydrogen/prefer-image-component': 'off',
'no-useless-escape': 'off',
'@typescript-eslint/no-non-null-asserted-optional-chain': 'off',
'no-case-declarations': 'off',
},
};
9 changes: 9 additions & 0 deletions framework-boilerplates/hydrogen-2/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
node_modules
/.cache
/build
/dist
/public/build
/.mf
.env
.shopify
.vercel
1 change: 1 addition & 0 deletions framework-boilerplates/hydrogen-2/.graphqlrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
schema: node_modules/@shopify/hydrogen-react/storefront.schema.json
3 changes: 3 additions & 0 deletions framework-boilerplates/hydrogen-2/.vercelignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.cache
dist
.shopify
48 changes: 48 additions & 0 deletions framework-boilerplates/hydrogen-2/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Hydrogen v2

This directory is a brief example of a [Hydrogen v2](https://shopify.dev/custom-storefronts/hydrogen) storefront that can be deployed to Vercel with zero configuration.

## Deploy Your Own

[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https://github.com/vercel/examples/tree/main/framework-boilerplates/hydrogen-2&template=hydrogen-2)

_Live Example: https://hydrogen-v2-template.vercel.app_

You can also deploy using the [Vercel CLI](https://vercel.com/docs/cli):

```sh
npm i -g vercel
vercel
```

Hydrogen is Shopify’s stack for headless commerce. Hydrogen is designed to dovetail with [Remix](https://remix.run/), Shopify’s full stack web framework. This template contains a **minimal setup** of components, queries and tooling to get started with Hydrogen.

[Check out Hydrogen docs](https://shopify.dev/custom-storefronts/hydrogen)
[Get familiar with Remix](https://remix.run/docs/en/v1)

## What's included

- Remix
- Hydrogen
- Oxygen
- Shopify CLI
- ESLint
- Prettier
- GraphQL generator
- TypeScript and JavaScript flavors
- Minimal setup of components and routes

## Environment Variables

Using Hydrogen requires a few [environment variables](https://shopify.dev/docs/custom-storefronts/hydrogen/environment-variables) to be set in order to properly connect to Shopify. For this template, the minimal set of environment variables are defined in the `vercel.json` file, which will be applied to the deployment when deployed to Vercel. However, you should migrate these default environment variables to your Project's Environment Variables configuration in the Vercel dashboard (or using the `vc env` commands), and update them according to your needs (also change the `SESSION_SECRET` to your own value). Once that is done, delete the `vercel.json` file from your project to prevent the environment variables defined there from taking precedence.

## Local development

Rename the `.env.example` file to `.env` in order for the Shopify dev server to use those environment variables during local development. If you defined/modified additional environment variables based on the section above, be sure to apply those changes in your `.env` file as well.

Then run the following commands:

```bash
npm install
npm run dev
```
47 changes: 47 additions & 0 deletions framework-boilerplates/hydrogen-2/app/components/Aside.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/**
* A side bar component with Overlay that works without JavaScript.
* @example
* ```ts
* <Aside id="search-aside" heading="SEARCH">`
* <input type="search" />
* ...
* </Aside>
* ```
*/
export function Aside({
children,
heading,
id = 'aside',
}: {
children?: React.ReactNode;
heading: React.ReactNode;
id?: string;
}) {
return (
<div aria-modal className="overlay" id={id} role="dialog">
<button
className="close-outside"
onClick={() => {
history.go(-1);
window.location.hash = '';
}}
/>
<aside>
<header>
<h3>{heading}</h3>
<CloseAside />
</header>
<main>{children}</main>
</aside>
</div>
);
}

function CloseAside() {
return (
/* eslint-disable-next-line jsx-a11y/anchor-is-valid */
<a className="close" href="#" onChange={() => history.go(-1)}>
&times;
</a>
);
}
Loading

0 comments on commit f3a11a2

Please sign in to comment.