Skip to content

Commit 36a768e

Browse files
balazsbajoricsjuanpprieto
authored andcommitted
React Router 7 (#2866)
* checkpoint: hydrogen lib is pulling in RR7 and types are fixed * Update plugin.ts * Update vite.config.ts * gitignore and eslint ignore changes * checkpoint: the skeleton is semi-updated, typecheck runs, npm run dev fails * stripping sharedOptions.remixConfig from the hydrogen vite plugin * updating remix-oxygen * remove the classic compiler option from hydrogen-cli * removing the classic remix example * removing the classic-remix example leftovers * checkpoint: CLI builds but the tests fail * fix json syntax error in skeleton tsconfig.json * changing all examples package jsons to match the skeleton * fixing typo * fixing two false detections of classic projects * removing @remix-run/fs-routes from root package.json * do I need react-router-dom in the skeleton too? * pruning remix-config.ts in cli * fixing tsconfig of cli * fixing types of hydrogen Pagination.ts * pruning exports from remix-oxygen/index.ts – note: all of these re-exports should be removed * removing outdated reference to @remix-run/server-runtime here * removing no-longer applicable remix-run reference * type fix in hydrogen / VariantSelector.ts * Update package-lock.json * updating ALL of the examples to React Router 7 via codemod * Update entry.server.tsx * it seems like the skeleton's build directory should be 'dist' according to CLI tests * _temporarily_ adding react-router-dom to the root package. this should be weeded out * respect HYDROGEN_DISABLE_VIRTUAL_ROUTES in hydrogenRoutes * prettier change * the auto-upgrade now ALSO works with react router * fixing build * CLI: temporarily skipping typecheck test * Update collections.$handle.tsx * fixing botched merge * running Prettier on package.json * adding this vite config v6 fix, just in case... but maybe we will remove this * oh god * a few more remix-runs * Update Footer.tsx * codegen now runs react-router typegen * removing react-router typegen from the typecheck command * Update package.json * fixing types in examples/express * skeleton env.d.ts refers to react-router now * fixing skeleton type errors * fixing examples/express/env.d.ts * fixing all the env.d.ts 'es * adding these env.d.ts es to fix the remaining example tsc failures * Update package-lock.json * Snapit: adding @shopify/remix-oxygen to the forced changeset * adding back three re-exported types from react-router * Update codegen.ts * adding .react-router to the skeleton gitignore * undo root .gitignore changes * react-router codegen supports watch flag now * reformatting codegen.ts * TODO BEFORE MERGE remove ALL references to legacy-runtime * fixing a few react-router imports * const REMIX_COMPILER_ERROR_MESSAGE * removing react-router and react-router-dom from the root dependencies * regenerated package-lock.json from the main baseline * Revert "regenerated package-lock.json from the main baseline" This reverts commit e5b074f. * Revert "removing react-router and react-router-dom from the root dependencies" This reverts commit 28fc65e. * pinning react-router to 7.6.0 * adding a changeset * adding cursor rule with hydrogen upgrade instructions * Update package-lock.json * simplifying skeleton's virtual import * Update thick-tigers-grab.md * removing all references to legacy-runtime * Update dev.env.d.ts * Update env.d.ts * scrubbing more references to legacyRuntime * whooops * re-enabling createContentSecurityPolicy example * try removing the HYDROGEN_DISABLE_VIRTUAL_ROUTES fix * will this test pass now, maybe? * removing two TODO BEFORE MERGEs as they are done! * removing remix-oxygen/src/implementations.ts * what happens if we only change the relevant parts in the vite.config.ts? * Delete upgrade-hydrogen-react-router-7-2025.5.0.mdc * Major version bumping libraries that now depend on react-router@7 * renaming remixBuild to reactRouterBuild
1 parent ba99d55 commit 36a768e

File tree

240 files changed

+1807
-1204
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

240 files changed

+1807
-1204
lines changed

.changeset/thick-tigers-grab.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
'@shopify/remix-oxygen': patch
3+
'skeleton': patch
4+
'@shopify/hydrogen': patch
5+
'@shopify/cli-hydrogen': patch
6+
'@shopify/create-hydrogen': patch
7+
---
8+
9+
Migrating to React Router 7

.changeset/warm-beers-fix.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@shopify/remix-oxygen": major
3+
"@shopify/cli-hydrogen": major
4+
"@shopify/hydrogen": patch
5+
---
6+
7+
Major version bumping libraries that now depend on react-router@7

cookbook/recipes/subscriptions/ingredients/templates/skeleton/app/components/SellingPlanSelector.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type {
44
SellingPlanFragment,
55
} from 'storefrontapi.generated';
66
import {useMemo} from 'react';
7-
import {useLocation} from '@remix-run/react';
7+
import {useLocation} from 'react-router';
88

99
/* Enriched sellingPlan type including isSelected and url */
1010
export type SellingPlan = SellingPlanFragment & {

examples/b2b/app/components/B2BLocationProvider.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {createContext, useContext, useEffect, useState, useMemo} from 'react';
2-
import {useFetcher} from '@remix-run/react';
2+
import {useFetcher} from 'react-router';
33
import {type CustomerCompany} from '~/root';
44

55
export type B2BLocationContextValue = {

examples/b2b/app/components/CartLineItem.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type {CartLineUpdateInput} from '@shopify/hydrogen/storefront-api-types';
22
import type {CartLayout} from '~/components/CartMain';
33
import {CartForm, Image, type OptimisticCartLine} from '@shopify/hydrogen';
44
import {useVariantUrl} from '~/lib/variants';
5-
import {Link} from '@remix-run/react';
5+
import {Link} from 'react-router';
66
import {ProductPrice} from '~/components/ProductPrice';
77
import {useAside} from '~/components/Aside';
88
import type {CartApiQueryFragment} from 'storefrontapi.generated';
@@ -113,7 +113,9 @@ function CartLineQuantity({line}: {line: CartLine}) {
113113
value={nextQuantity}
114114
/***********************************************/
115115
/********** EXAMPLE UPDATE STARTS ************/
116-
disabled={Boolean(maximum && nextQuantity > maximum || !!isOptimistic)}
116+
disabled={Boolean(
117+
(maximum && nextQuantity > maximum) || !!isOptimistic,
118+
)}
117119
/********** EXAMPLE UPDATE END ************/
118120
/***********************************************/
119121
>

examples/b2b/app/components/Header.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {Suspense} from 'react';
2-
import {Await, NavLink} from '@remix-run/react';
2+
import {Await, NavLink} from 'react-router';
33
import {type CartViewPayload, useAnalytics} from '@shopify/hydrogen';
44
import type {HeaderQuery, CartApiQueryFragment} from 'storefrontapi.generated';
55
import {useAside} from '~/components/Aside';

examples/b2b/app/components/ProductForm.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Link, useNavigate} from '@remix-run/react';
1+
import {Link, useNavigate} from 'react-router';
22
import {type MappedProductOptions} from '@shopify/hydrogen';
33
import type {
44
Maybe,
@@ -104,7 +104,7 @@ export function ProductForm({
104104
</div>
105105
<br />
106106
</div>
107-
)
107+
);
108108
})}
109109
<br />
110110
<AddToCartButton

examples/b2b/app/root.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import {useNonce, getShopAnalytics, Analytics} from '@shopify/hydrogen';
2-
import {type LoaderFunctionArgs} from '@shopify/remix-oxygen';
32
import {
43
Links,
54
Meta,
@@ -9,8 +8,9 @@ import {
98
useRouteLoaderData,
109
ScrollRestoration,
1110
isRouteErrorResponse,
11+
type LoaderFunctionArgs,
1212
type ShouldRevalidateFunction,
13-
} from '@remix-run/react';
13+
} from 'react-router';
1414
import favicon from '~/assets/favicon.svg';
1515
import resetStyles from '~/styles/reset.css?url';
1616
import appStyles from '~/styles/app.css?url';

examples/b2b/app/routes/b2blocations.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import {type LoaderFunctionArgs} from '@shopify/remix-oxygen';
2-
import {useLoaderData} from '@remix-run/react';
1+
import {type LoaderFunctionArgs, useLoaderData} from 'react-router';
32
import {B2BLocationSelector} from '../components/B2BLocationSelector';
43
import {CUSTOMER_LOCATIONS_QUERY} from '~/graphql/customer-account/CustomerLocationsQuery';
54

examples/b2b/app/routes/products.$handle.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
import {type LoaderFunctionArgs} from '@shopify/remix-oxygen';
2-
import {useLoaderData, type MetaFunction} from '@remix-run/react';
1+
import {
2+
useLoaderData,
3+
type LoaderFunctionArgs,
4+
type MetaFunction,
5+
} from 'react-router';
36
import {
47
getSelectedProductOptions,
58
Analytics,

0 commit comments

Comments
 (0)