Skip to content

feat(react-router-express): support non-express servers #13742

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

43081j
Copy link

@43081j 43081j commented Jun 4, 2025

We don't actually use any express specific functionality, so can change our handlers to accept the lower level interfaces instead (IncomingMessage and ServerResponse).

This means servers like polka can also use the react-router-express middleware.

We don't actually use any express specific functionality, so can change
our handlers to accept the lower level interfaces instead
(`IncomingMessage` and `ServerResponse`).

This means servers like `polka` can also use the react-router-express
middleware.
Copy link

changeset-bot bot commented Jun 4, 2025

🦋 Changeset detected

Latest commit: 676a8c4

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

This PR includes changesets to release 11 packages
Name Type
@react-router/express Major
@react-router/serve Major
@react-router/dev Major
@react-router/fs-routes Major
@react-router/remix-routes-option-adapter Major
create-react-router Major
react-router Major
react-router-dom Major
@react-router/architect Major
@react-router/cloudflare Major
@react-router/node Major

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

Copy link
Member

@MichaelDeBoey MichaelDeBoey left a comment

Choose a reason for hiding this comment

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

I'm going to refer to @brophdawg11's remix-run/remix#7086 (comment)

Remix doesn't depend on Express - Remix runs on the Web Fetch API - this is just an adapter for Express to convert Express requests into Fetch Requests that can be handled by Remix. So it doesn't make sense to remove the express dependency.

Since express is already listed in peerDependencies, I think @TrySound's concern (see remix-run/remix#7086 (comment)) about making the Express adapter smaller is kinda obsolete now?

Since @react-router/dev also isn't using express anymore (@remix-run/dev was), a resubmission of @TrySound's remix-run/remix#7087 also doesn't seem necessary to me.
Unless I'm missing something?

@43081j
Copy link
Author

43081j commented Jun 5, 2025

Forgetting install size for a moment - this change means we can use the middleware in any express-like server.

Currently, it can be used with express but not much else. As mentioned in those comments, we could just make an adapter per web server. or we could just make this adapter work in all of them (this change).

Like most express middleware, it is still built for express but can be used in other servers with a compatible API then too

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