Skip to content

[DO NOT MERGE] Upgrade to react router#27

Open
byrichardpowell wants to merge 14 commits intomainfrom
upgrade-to-react-router
Open

[DO NOT MERGE] Upgrade to react router#27
byrichardpowell wants to merge 14 commits intomainfrom
upgrade-to-react-router

Conversation

@byrichardpowell
Copy link
Contributor

@byrichardpowell byrichardpowell commented Jun 17, 2025

How to use this PR

This PR shows how to upgrade an out of date version of the Shopify Remix app template to React Router that has not yet adopted Vite. It breaks changes into logical commits that follow the migrations guides:

If you want to understand each change, you can follow the commits in order. Alternatively, you can look at all the changes as one and copy them across to your app.

Most likely you won't need all the changes in this PR. The QR Code example hasn't kept up to date with the latest versions of @shopify/shopify-app-remix and you probably created your app after we created this one.

DO NOT MERGE

Keeping this open as a demonstration of upgrading an app from Remix to React Router

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR migrates the Shopify Remix template to React Router v7 by replacing Remix-specific adapters, APIs, and configurations with React Router equivalents and updating the build toolchain to Vite.

  • Switch server/client routing from Remix to React Router (imports, adapters, <ServerRouter>, loader/action returns)
  • Update package.json scripts, dependencies (Vite build, type: "module", engines, React Router packages)
  • Adjust route components, CSS handling, and error boundary to align with React Router conventions

Reviewed Changes

Copilot reviewed 27 out of 27 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
react-router.config.ts Added React Router dev server configuration
package.json Updated scripts, added ESM, Vite build, React Router deps
app/shopify.server.js Switched to React Router–compatible Shopify server adapter
app/routes/**/*.jsx Replaced @remix-run/* imports with react-router, plain returns
app/routes/app._index.jsx Import/update loader return, added headers export via boundary
app/routes/_index/route.jsx Removed Remix links, updated redirect/form imports
app/routes.js Introduced flatRoutes entry
app/root.jsx Switched root imports to React Router, added lang="en"
app/entry.server.jsx Replaced <RemixServer> with <ServerRouter>, updated timeout
.graphqlrc.js Updated LATEST_API_VERSION import path
Comments suppressed due to low confidence (3)

app/routes/app._index.jsx:6

  • You removed the links() export that injects the stylesheet; importing the URL alone won’t include it in the page. Consider re-adding a links() function that returns { rel: 'stylesheet', href: styles }.
import "./styles.css?url";

app/routes/qrcodes.$id.jsx:2

  • The loader now returns a plain object instead of json. Add or update tests to verify that useLoaderData correctly receives title and image properties under React Router.
import { useLoaderData } from "react-router";

app/routes/_index/route.jsx:6

  • The CSS import needs a corresponding links() export for React Router to add a <link> tag. Without it, your styles won’t load in the browser.
import "./styles.css?url";

@byrichardpowell byrichardpowell changed the title Upgrade to react router [WIP] [DO NOT MERGE] Upgrade to react router Jun 17, 2025
@byrichardpowell byrichardpowell force-pushed the upgrade-to-react-router branch 3 times, most recently from c1ca960 to 80d72b2 Compare June 24, 2025 20:35
@byrichardpowell byrichardpowell force-pushed the upgrade-to-react-router branch 13 times, most recently from 925968d to 35b47ba Compare July 2, 2025 13:54
@byrichardpowell byrichardpowell force-pushed the upgrade-to-react-router branch 4 times, most recently from d0cd359 to cdfe73e Compare July 10, 2025 20:21
@byrichardpowell byrichardpowell force-pushed the upgrade-to-react-router branch 5 times, most recently from 7d1f914 to 3abf441 Compare July 17, 2025 14:42
…ependency, then expressing the predev command in the sopify.web.toml
…main/start/future-flags#v3_singlefetch

Adopting this flag requires:

1. Adding  everywhere that calls authenticate.admin().  In the template, there is just one place where this is missing, which is why I added it to app._index.tsx
2. Adding declare module @remix-run/node to the vite.config.ts file
3. Removing json() from every loader/action that uses it
@byrichardpowell byrichardpowell force-pushed the upgrade-to-react-router branch from 3abf441 to 6a5a658 Compare July 22, 2025 19:33
@byrichardpowell byrichardpowell changed the title [WIP] [DO NOT MERGE] Upgrade to react router [DO NOT MERGE] Upgrade to react router Sep 30, 2025
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.

3 participants