Skip to content

Adapt React Router autoconfig based on v8_middleware future flag#14132

Merged
dario-piotrowicz merged 4 commits into
mainfrom
dario/autoconfig-react-router-v8-middleware
Jun 1, 2026
Merged

Adapt React Router autoconfig based on v8_middleware future flag#14132
dario-piotrowicz merged 4 commits into
mainfrom
dario/autoconfig-react-router-v8-middleware

Conversation

@dario-piotrowicz

@dario-piotrowicz dario-piotrowicz commented May 31, 2026

Copy link
Copy Markdown
Member

Fixes the broken C3 React Router experimental E2E.
(The E2E was broken because ReactRouter introduced the use of the flag in their starter templates in remix-run/react-router-templates#210 which breaks the Cloudflare integration)

The React Router autoconfig (wrangler setup) now detects whether v8_middleware: true is set in the user's react-router.config.ts. When it is, the generated workers/app.ts uses a simplified fetch handler without AppLoadContext module augmentation, and the generated app/entry.server.tsx omits the _loadContext parameter. When v8_middleware is not set, the existing AppLoadContext pattern with env/ctx params is preserved.

This avoids breaking projects that use the v8_middleware future flag (which changes the context API from AppLoadContext to RouterContextProvider), while keeping the traditional pattern for projects that haven't opted in.


  • Tests
    • Tests included/updated
    • Automated tests not possible - manual testing has been completed as follows:
    • Additional testing not necessary because:
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: self-explanatory fix

A picture of a cute animal (not mandatory, but encouraged)

@changeset-bot

changeset-bot Bot commented May 31, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 0367e0e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
wrangler Patch
@cloudflare/vite-plugin Patch
@cloudflare/vitest-pool-workers Patch
@cloudflare/wrangler-bundler Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions

github-actions Bot commented May 31, 2026

Copy link
Copy Markdown
Contributor

✅ All changesets look good

@ask-bonk ask-bonk Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Solid change — the refactoring into helper functions is clean, tests cover both branches well, and the AST visitor logic is correct. One potential robustness issue below.

Comment thread packages/wrangler/src/autoconfig/frameworks/react-router.ts
@ask-bonk

This comment was marked as resolved.

Comment thread packages/wrangler/src/autoconfig/frameworks/react-router.ts
@dario-piotrowicz dario-piotrowicz force-pushed the dario/autoconfig-react-router-v8-middleware branch 2 times, most recently from 1833c75 to c06771c Compare June 1, 2026 00:10
@pkg-pr-new

pkg-pr-new Bot commented Jun 1, 2026

Copy link
Copy Markdown
create-cloudflare

npm i https://pkg.pr.new/cloudflare/workers-sdk/create-cloudflare@14132

@cloudflare/deploy-helpers

npm i https://pkg.pr.new/cloudflare/workers-sdk/@cloudflare/deploy-helpers@14132

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/cloudflare/workers-sdk/@cloudflare/kv-asset-handler@14132

miniflare

npm i https://pkg.pr.new/cloudflare/workers-sdk/miniflare@14132

@cloudflare/pages-shared

npm i https://pkg.pr.new/cloudflare/workers-sdk/@cloudflare/pages-shared@14132

@cloudflare/unenv-preset

npm i https://pkg.pr.new/cloudflare/workers-sdk/@cloudflare/unenv-preset@14132

@cloudflare/vite-plugin

npm i https://pkg.pr.new/cloudflare/workers-sdk/@cloudflare/vite-plugin@14132

@cloudflare/vitest-pool-workers

npm i https://pkg.pr.new/cloudflare/workers-sdk/@cloudflare/vitest-pool-workers@14132

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/cloudflare/workers-sdk/@cloudflare/workers-editor-shared@14132

@cloudflare/workers-utils

npm i https://pkg.pr.new/cloudflare/workers-sdk/@cloudflare/workers-utils@14132

wrangler

npm i https://pkg.pr.new/cloudflare/workers-sdk/wrangler@14132

@cloudflare/wrangler-bundler

npm i https://pkg.pr.new/cloudflare/workers-sdk/@cloudflare/wrangler-bundler@14132

commit: 0367e0e

@dario-piotrowicz dario-piotrowicz added the run-c3-frameworks-tests Run all the C3 frameworks tests on this PR label Jun 1, 2026
@dario-piotrowicz dario-piotrowicz marked this pull request as ready for review June 1, 2026 00:49
@workers-devprod workers-devprod requested review from a team and edmundhung and removed request for a team June 1, 2026 00:49
@workers-devprod

workers-devprod commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • ✅ @cloudflare/wrangler
Show detailed file reviewers

Comment thread packages/wrangler/src/autoconfig/frameworks/react-router.ts

@workers-devprod workers-devprod left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Codeowners reviews satisfied

@github-project-automation github-project-automation Bot moved this from Untriaged to Approved in workers-sdk Jun 1, 2026
@dario-piotrowicz dario-piotrowicz force-pushed the dario/autoconfig-react-router-v8-middleware branch from c75bd8e to 0367e0e Compare June 1, 2026 12:40
@dario-piotrowicz dario-piotrowicz merged commit 2dffeeb into main Jun 1, 2026
53 checks passed
@dario-piotrowicz dario-piotrowicz deleted the dario/autoconfig-react-router-v8-middleware branch June 1, 2026 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

run-c3-frameworks-tests Run all the C3 frameworks tests on this PR

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants