Skip to content

Conversation

@edmundhung
Copy link

@edmundhung edmundhung commented Jan 29, 2026

This PR adds a default entry.server.tsx using renderToReadableStream.

Previously, users without @react-router/node had to provide a custom server entry. Now React Router uses a web-streams based entry when @react-router/node isn't listed in dependencies, which supports both non-Node runtimes and modern Node versions with React 19.2.0+.

  • An extra runtime check is added to the default entry with helpful error messages for misconfigured setups.
  • The reveal command returns the corresponding entry based on whether @react-router/node is listed.

@changeset-bot
Copy link

changeset-bot bot commented Jan 29, 2026

⚠️ No Changeset found

Latest commit: 4af667d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@remix-cla-bot
Copy link
Contributor

remix-cla-bot bot commented Jan 29, 2026

Hi @edmundhung,

Welcome, and thank you for contributing to React Router!

Before we consider your pull request, we ask that you sign our Contributor License Agreement (CLA). We require this only once.

You may review the CLA and sign it by adding your name to contributors.yml.

Once the CLA is signed, the CLA Signed label will be added to the pull request.

If you have already signed the CLA and received this response in error, or if you have any questions, please contact us at [email protected].

Thanks!

- The Remix team

@remix-cla-bot
Copy link
Contributor

remix-cla-bot bot commented Jan 30, 2026

Thank you for signing the Contributor License Agreement. Let's get this merged! 🥳

@edmundhung edmundhung force-pushed the default-server-entry-web branch from dd552d8 to 188d4a3 Compare January 30, 2026 13:10
Comment on lines +6 to +13
// ReactDOMServer.renderToReadableStream is not available in Node.js until React 19.2.0+
if (typeof ReactDOMServer.renderToReadableStream !== "function") {
throw new Error(
`ReactDOMServer.renderToReadableStream() is not available. ` +
`React Router uses this API when @react-router/node is not installed. ` +
`Please install @react-router/node, or provide a custom entry.server.tsx/jsx file in your app directory.`,
);
}
Copy link
Author

Choose a reason for hiding this comment

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

The check is still needed because renderToReadableStream is only available in Node.js from React 19.2.0+.

Without this check, users on React 18.x or React 19.0.0-19.1.x running on Node.js would get a cryptic error because renderToReadableStream is undefined.

Comment on lines +10 to +17
// ReactDOMServer.renderToPipeableStream is only available in Node.js
if (typeof ReactDOMServer.renderToPipeableStream !== "function") {
throw new Error(
`Running the Node.js server entry on a non-Node runtime. ` +
`React Router uses this when @react-router/node is listed in your dependencies. ` +
`Remove it, or provide a custom entry.server.tsx/jsx file in your app directory.`,
);
}
Copy link
Author

Choose a reason for hiding this comment

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

This helps users migrating from Node.js to non-Node runtimes. If they forget to remove @react-router/node, React Router selects this entry but renderToPipeableStream won't be available.

The check provides a clear error message instead of a cryptic failure.

@edmundhung edmundhung changed the title feat: add default server entry for non-Node runtimes feat: add default web-streams based server entry Jan 30, 2026
@brophdawg11
Copy link
Contributor

We moved away from this "dependency detection" approach in v7 but I don't recall the specific underlying reason. I'm hesitant to add it back without tracking that down and seeing if it still applies and/or should be reconsidered.

@edmundhung
Copy link
Author

We moved away from this "dependency detection" approach in v7 but I don't recall the specific underlying reason. I'm hesitant to add it back without tracking that down and seeing if it still applies and/or should be reconsidered.

Good to know that. I'm curious what the dependency detection was being used for? Was it for something beyond server entry files?

I can understand why it might not be preferred. Happy to explore alternatives.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants