How to implement renderToPipeableStream with the streaming API?
Is this even a correct use-case for the hono streaming api?
7 Replies
You can pipe a readable stream to the hono stream that gets returned to the client
Idk if
pipe
in your snippet is a readable stream. I haven’t used that lib.
If it’s not, maybe the lib has a readable stream method?
As far as error responses, it doesn’t look like you can return a 500. Once the stream is opened, you’re locked in
https://hono.dev/docs/helpers/streamingReact server has a renderToReadableStream but it is not supported in node enviroments.
When does the stream open? When you first put data inside or earlier? onShellReady and onShellError are exclusive.
By the time the callback is called, I think. Check the docs I linked
"However, when the callback function is executed, the stream has already started, so it cannot be overwritten."
Okay thanks, so i cannot use the streaming api.
I guess not
What’s your goal/motivation?
I want to SSR stream react with hono (nodejs)
https://react.dev/reference/react-dom/server/renderToPipeableStream
I got it working using a promise based approach:
renderToPipeableStream – React
The library for web and native user interfaces
dope! thanks for sharing your solution