Meteor and React 18

I tried to test Meteor 2.3.4 and React 18 alpha. It works.
I tried SSR with renderToString function which is not recommended but it works.
I’ve not tested with new suspend and lazy yet
Here is the repository: GitHub - minhna/meteor-react-18

Does anyone know how to implement pipeToNodeWritable function?

You might be able to do it kind of like this.

3 Likes

I got a chance today to explore this.

renderToString() works as posted above. The problem is that it only works with the legacy version of Suspense

renderToNodeStream() works but is deprecated. Also limited to legacy Suspense

renderToPipeableStream() did not work because the output is not html but are functions that can be used to stream the results. Ideally, it must be passed to webapp to handle the streaming of the content but with a couple of caveats:
1.) it does not use the html template file
2.) the options does not have a way to attach head tags other than scripts

Conclusion: There is currently no clear path to implement both SSR and Lazy Loading at the same time using Meteor + React 18.

Tested with Meteor 2.9.1 and React 18.2

1 Like

Suspense can work with React’s data strategy for async data source even in the server (can see the promise resolving and data being available).

The only problem is that I cannot make the stream to work so the suspended component is not updating in the client.

@piotrpospiech looked into it and it’s definitely possible: adds fetchAsync to useFindServer by eduwr · Pull Request #360 · meteor/react-packages · GitHub, but with some limitations. There’s no one looking into it now, at least as far as I know, so feel free to do that. If you’d need to some help, I guess I could help.

2 Likes

Thanks for pointing me to the discussion. I should have read that before digging into this.

I will provide feedback as I will also be looking at webapp to create a middleware to handle this.

1 Like