react-server icon indicating copy to clipboard operation
react-server copied to clipboard

Example usage within express ?

Open revskill10 opened this issue 1 year ago • 3 comments

Could we embed the middleware within an express app ?

revskill10 avatar Apr 20 '24 15:04 revskill10

Hi @revskill10! It's not impossible, but the current implementation is not supporting it out of the box. The framework is meant to run as a standalone node.js app right now and it's using HatTip for the HTTP layer.

Keep in mind that this is only an experimental framework for testing and learning exercises about React Server Components and the challenges of creating a framework which supports the latest React SSR features. The framework might become more in the future, but it would need a refactor as newer versions of React introduced breaking changes and this framework is not compatible anymore with latest experimental React versions. But thanks for opening the issue!

lazarv avatar Apr 24 '24 20:04 lazarv

@lazarv Thanks for the insights.

I'm trying to integrate react-server with nest.js framework.

It would be awesome if you could extract the react-server part there.

revskill10 avatar Apr 25 '24 03:04 revskill10

Hi @revskill10! I have some good news!

Here you can find some documentation to the new "middleware mode" of the framework. https://react-server.dev/guide/framework/middleware-mode

Also I created 2 small examples for Express.js and Nest.js at https://github.com/lazarv/react-server/tree/main/examples/express and https://github.com/lazarv/react-server/tree/main/examples/nestjs.

Please let me know if something is not working as expected. Right now it's a bit inconvenient how you can import the framework modules into the Nest.js project with the current TypeScript setup, but this is mostly a POC and can be enhanced later.

Please check out the documentation! I would really appreciate any feedback. Thanks!

lazarv avatar May 23 '24 21:05 lazarv

Hey guys! @lazarv, what would a Socket.io implementation with react-server look like? I tried to follow the example of the integration with express, without success and I still lose the server routes.

ericdmachado avatar May 16 '25 17:05 ericdmachado

Hey @ericdmachado! You tried to add a Socket.io implementation to the Express example at https://github.com/lazarv/react-server/tree/main/examples/express? Can you provide more details on your issue, or can you share a minimum reproduction of your issue? If something doesn't work regarding middleware mode, please open a new issue.

lazarv avatar May 21 '25 22:05 lazarv