Skip to content

Conversation

@serhalp
Copy link
Member

@serhalp serhalp commented Nov 5, 2025

Description

Follow-up to #562. It turns out react-router dev does not work with the new edge mode as documented. This is because React Router uses the user's server entry file, which is intentionally intended for an edge runtime, and unfortunately incompatible with a Node.js runtime, which it uses in dev.

There's some more sophisticated solution involving the Vite Environment API we can look into down the line, but for now I just ported something very similar to what we do for Remix: have users write a one-liner server entry that uses our Vite virtual module that conditionally resolves depending on build (edge entry) vs. dev (node.js entry).

As a bonus, the file for users to copy is a single line instead of 40 🎉.

@netlify
Copy link

netlify bot commented Nov 5, 2025

Deploy Preview for remix-edge ready!

Name Link
🔨 Latest commit 76413c1
🔍 Latest deploy log https://app.netlify.com/projects/remix-edge/deploys/690cb6643250c80008be8744
😎 Deploy Preview https://deploy-preview-572--remix-edge.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link

netlify bot commented Nov 5, 2025

Deploy Preview for remix-serverless ready!

Name Link
🔨 Latest commit 76413c1
🔍 Latest deploy log https://app.netlify.com/projects/remix-serverless/deploys/690cb664cdf3570008acc64d
😎 Deploy Preview https://deploy-preview-572--remix-serverless.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions github-actions bot added the type: bug code to address defects in shipped code label Nov 5, 2025
@serhalp serhalp changed the title fix(@netlify/vite-plugin-react-router): fix local dev in with edge: true fix(@netlify/vite-plugin-react-router): fix local de with edge: true Nov 5, 2025
@serhalp serhalp changed the title fix(@netlify/vite-plugin-react-router): fix local de with edge: true fix(@netlify/vite-plugin-react-router): fix local dev with edge: true Nov 5, 2025
@serhalp serhalp force-pushed the fix/edge-dev-entry branch 2 times, most recently from c0c34b0 to 4bb55b6 Compare November 5, 2025 22:21
Comment on lines 61 to 62
"@netlify/edge-functions": "^3.0.2",
"@netlify/functions": "^5.1.0",
Copy link
Member Author

Choose a reason for hiding this comment

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

Not completely related, but these shouldn't be dev deps anymore, since they're needed for the netlifyRouterContext export added in 2.0.0.

@serhalp serhalp force-pushed the fix/edge-dev-entry branch from 4bb55b6 to f255a7d Compare November 5, 2025 22:36
@serhalp serhalp marked this pull request as ready for review November 5, 2025 22:37
@serhalp serhalp requested a review from a team as a code owner November 5, 2025 22:37
because why not
These are now needed at runtime when importing `netlifyRouterContext`.
There's some more sophisticated solution involving the Vite Environment API down the line, but for
now I just ported something very similar to what we do for Remix: have users write a one-liner
server entry to uses our Vite virtual module that conditionally resolves depending on build (edge
entry) vs. dev (node.js entry).

As a bonus, the file for users to copy is a single line instead of 40.
@serhalp serhalp force-pushed the fix/edge-dev-entry branch from f255a7d to 018f127 Compare November 5, 2025 22:49
@serhalp serhalp enabled auto-merge (squash) November 6, 2025 14:53
@serhalp serhalp merged commit dfb27c1 into main Nov 6, 2025
16 checks passed
@serhalp serhalp deleted the fix/edge-dev-entry branch November 6, 2025 15:02
@token-generator-app token-generator-app bot mentioned this pull request Nov 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: bug code to address defects in shipped code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants