Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR was opened by the Changesets release GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to v1.x-2022-07, this PR will be updated.
Releases
[email protected]
Minor Changes
#912
de0e0d6a
Thanks @blittle! - Change the country selector to lazy load available countries. The motivation to do so is that a lot of countries come with the starter template. The problem is 1) the graphql query to fetch them all is relatively slow and 2) all of them get serialized to the browser in each RSC response.This change removes
availableCountries
from theLocalizationProvider
. As a result, theuseAvailableCountries
hook is also gone. Instead, the available countries are loaded on demand from an API route.Migratation steps:
Create an API route to retrieve available countries:
Then within your client code, query the API route with a
useEffect
hook:See an example on how this could be done inside the Hydrogen Example Template country selector
#698
6f30b9a1
Thanks @jplhomer! - Basic end-to-end tests have been added to the default Hydrogen template. You can run tests in development:yarn test
Or in continuous-integration (CI) environments:
#846
58c823b5
Thanks @blittle! - ## New<Route>
ComponentThe
<Route>
component is available for routes not defined by the file system. The<Route>
component must be used within the<Router>
component.<Route>
accepts two props:path
string
/products/:handle
.page
A rendered Server Component reference
Changes to
<Router>
You can have multiple
<Route>
and<FileRoutes>
components in your app. Hydrogen will only render one route for each request — whichever it finds first. This means the<Router>
component no longer takesfallback
as a prop. It also doesn't needserverProps
. Instead, to render a 404 "Not Found" page, add<Route path="*" page={<NotFound />} />
to your app. Make sure it's the last<Route>
defined inside your app:Changes to
<FileRoutes>
The
<FileRoutes>
component now accepts two additional optional props:basePath
string
"/"
dirPrefix
string
"./routes"
You need to modify
dirPrefix
if you want to import routes from a location other thansrc/routes
.You can modify
basePath
if you want to prefix all file routes. For example, you can prefix all file routes with a locale:New
useRouteParams()
hookYou can use the
useRouteParams()
hook to retrieve the parameters of an active route. The hook is available in both server and client components:#842
626e58ee
Thanks @wizardlyhel! - Removed theRawhtml
component.Upgrade your project by replacing references to the
RawHtml
component to followReact's
dangerouslySetInnerHTML
:Change all
RawHtml
componentto jsx equivalent
Patch Changes
#906
4db9534c
Thanks @blittle! - Optimize the GraphQL query for the home page#965
cdad13ed
Thanks @blittle! - Fix server redirects to work properly with RSC responses. For example, the redirect component within the starter template needs to change:This server component is rendered two ways:
response.redirect(...)
returns a component which will redirect on the client.#758
0bee3af0
Thanks @frandiox! - Upgrade to React experimental version0.0.0-experimental-2bf7c02f0-20220314
.To upgrade your Hydrogen app, change the pinned version of
react
andreact-dom
in yourpackage.json
file to this version, or run:#917
be888259
Thanks @jplhomer! - Add accessible button label for mobile navigation#918
5699e0e9
Thanks @michenly! - Optimize the GraphQL query for products page#926
0ca1a039
Thanks @frandiox! - Added a new default worker entry point that uses module syntax in@shopify/hydrogen/platforms/worker
.#903
dd33f7ef
Thanks @blittle! - Optimize the GraphQL query for the NotFound.server.jsx page#897
c01044e6
Thanks @blittle! - Add new custom headers for storefront API calls. See Issue #660#872
d90bb3be
Thanks @jplhomer! - Fix usage of NotFound when it is not possible to modify theresponse
object[email protected]
Minor Changes
a362a5dd
Thanks @cartogram! - Breaking Change: New rulesclient-component-banned-hooks
andserver-component-banned-hooks
added as generic rules to ban any non-supported hooks in each context.server-component-banned-hooks
combines and replaces theno-state-in-server-components
andno-effects-in-server-components
rules.client-component-banned-hooks
will flag usage ofuseQuery
anduseShopQuery
in client components.@shopify/[email protected]
Minor Changes
#922
b5eaddc1
Thanks @frehner! - Fragments and their related types have been removed:These fragments have been removed to reduce the chances of over-fetching (in other words, querying for fields you don't use) in your GraphQL queries. Please refer to the Storefront API documentation for information and guides.
#912
de0e0d6a
Thanks @blittle! - Change the country selector to lazy load available countries. The motivation to do so is that a lot of countries come with the starter template. The problem is 1) the graphql query to fetch them all is relatively slow and 2) all of them get serialized to the browser in each RSC response.This change removes
availableCountries
from theLocalizationProvider
. As a result, theuseAvailableCountries
hook is also gone. Instead, the available countries are loaded on demand from an API route.Migratation steps:
Create an API route to retrieve available countries:
Then within your client code, query the API route with a
useEffect
hook:See an example on how this could be done inside the Hydrogen Example Template country selector
#698
6f30b9a1
Thanks @jplhomer! - Basic end-to-end tests have been added to the default Hydrogen template. You can run tests in development:yarn test
Or in continuous-integration (CI) environments:
#932
507c5cbf
Thanks @jplhomer! - Adds CSS Modules support. Hydrogen now includes a Vite plugin that collects styles for each CSS Module and exports them to aStyleTag
component. To use CSS Modules in your Hydrogen app, you must render the style tag in the component along with your styles:Explore an example implementation of CSS Modules in GitHub.
#846
58c823b5
Thanks @blittle! - ## New<Route>
ComponentThe
<Route>
component is available for routes not defined by the file system. The<Route>
component must be used within the<Router>
component.<Route>
accepts two props:path
string
/products/:handle
.page
A rendered Server Component reference
Changes to
<Router>
You can have multiple
<Route>
and<FileRoutes>
components in your app. Hydrogen will only render one route for each request — whichever it finds first. This means the<Router>
component no longer takesfallback
as a prop. It also doesn't needserverProps
. Instead, to render a 404 "Not Found" page, add<Route path="*" page={<NotFound />} />
to your app. Make sure it's the last<Route>
defined inside your app:Changes to
<FileRoutes>
The
<FileRoutes>
component now accepts two additional optional props:basePath
string
"/"
dirPrefix
string
"./routes"
You need to modify
dirPrefix
if you want to import routes from a location other thansrc/routes
.You can modify
basePath
if you want to prefix all file routes. For example, you can prefix all file routes with a locale:New
useRouteParams()
hookYou can use the
useRouteParams()
hook to retrieve the parameters of an active route. The hook is available in both server and client components:#842
626e58ee
Thanks @wizardlyhel! - Removed theRawhtml
component.Upgrade your project by replacing references to the
RawHtml
component to followReact's
dangerouslySetInnerHTML
:Change all
RawHtml
componentto jsx equivalent
Patch Changes
#870
4c0fcd8f
Thanks @frandiox! - Remove useQuery hook from client exports to avoid leaking server logic to the browser.#950
d19fc36b
Thanks @frandiox! - Allow disabling minification in vite.config.js#981
8dda8a86
Thanks @michenly! - Fix useUrl() when it is in RSC mode#965
cdad13ed
Thanks @blittle! - Fix server redirects to work properly with RSC responses. For example, the redirect component within the starter template needs to change:This server component is rendered two ways:
response.redirect(...)
returns a component which will redirect on the client.#904
1b46f8d0
Thanks @wizardlyhel! - Log query key when provided in string#758
0bee3af0
Thanks @frandiox! - Upgrade to React experimental version0.0.0-experimental-2bf7c02f0-20220314
.To upgrade your Hydrogen app, change the pinned version of
react
andreact-dom
in yourpackage.json
file to this version, or run:#895
1017b541
Thanks @frandiox! - Improve error thrown in development when entry point fails on load.#897
c01044e6
Thanks @blittle! - Add new custom headers for storefront API calls. See Issue #660#908
8f4cd100
Thanks @mcvinci! - Hydrogen docs: Updates to align with latest release#871
4cb07c73
Thanks @scottdixon! - Hydrogen docs: Update ProductProvider example query#878
587aa3e6
Thanks @frandiox! - Fix preloading queries in workers to prevent waterfall requests.Breaking change:
fetchBuilder
no longer accepts aRequest
argument. Instead, it now accepts aurl: string
andoptions: FetchInit
:#923
993be985
Thanks @frandiox! - Provide a Logger option to use GraphQL and disable by default. Improve logging of unused query properties.#960
2e8a5ea2
Thanks @mcvinci! - Hydrogen docs: Add reference to robots.txt.server.js file@shopify/[email protected]
Patch Changes
8f4cd100
Thanks @mcvinci! - Hydrogen docs: Updates to align with latest release@shopify/[email protected]
Patch Changes
8f4cd100
Thanks @mcvinci! - Hydrogen docs: Updates to align with latest release