Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bl express node example #976

Merged
merged 8 commits into from
Jun 5, 2023
Merged

Bl express node example #976

merged 8 commits into from
Jun 5, 2023

Conversation

blittle
Copy link
Contributor

@blittle blittle commented Jun 2, 2023

WHY are these changes introduced?

This is an example setup where we have adapted the Remix Express starter app to use Hydrogen. A few things are not yet functional:

  1. The app does not have a cache implementation. So sub-requests to the Storefront API won't be cachable.
  2. The app does not yet utilize storefrontRedirect. This will be added when Remix releases middleware.
  3. The app only includes a single index route. If you'd like to add more routes, run the Shopify CLI: npx shopify hydrogen generate route

Also I updated the CLI to allow the route generation to work in non-oxygen hydrogen apps.

Copy link
Member

@benjaminsehl benjaminsehl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is awesome, Bret — thanks for doing this.

examples/express/README.md Outdated Show resolved Hide resolved
This is an example setup where we have adapted the Remix Express starter app to use Hydrogen. A few things are not yet functional:

1. The app does not have a cache implementation. So sub-requests to the Storefront API won't be cachable.
1. The app does not yet utilize [`storefrontRedirect`](https://shopify.dev/docs/api/hydrogen/2023-04/unstable/utilities/storefrontredirect). This will be added when Remix releases middleware.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
1. The app does not yet utilize [`storefrontRedirect`](https://shopify.dev/docs/api/hydrogen/2023-04/unstable/utilities/storefrontredirect). This will be added when Remix releases middleware.
1. Our [`storefrontRedirect`](https://shopify.dev/docs/api/hydrogen/2023-04/unstable/utilities/storefrontredirect) function, which handles redirects that are set in the Shopify Admin, must be set up in your server file. As the shape of the response isn't guaranteed, we haven't included this here. When Middleware is available in Remix, we'll add this into the example, until then, you can look to our [source code](https://github.com/Shopify/hydrogen/blob/2023-04/packages/hydrogen/src/routing/redirect.ts) to create your own implementation.

Copy link
Contributor

@frandiox frandiox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Bret!

Just one thing, this example is missing .env so it doesn't work out of the box. You probably have it locally but it wasn't added to the PR. Can you force add it?

examples/express/server.js Outdated Show resolved Hide resolved
examples/express/app/routes/_index.tsx Outdated Show resolved Hide resolved
examples/express/app/routes/_index.tsx Outdated Show resolved Hide resolved
@blittle blittle merged commit 808ceb5 into 2023-04 Jun 5, 2023
10 checks passed
@blittle blittle deleted the bl-express-node-example branch June 5, 2023 20:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants