honojs/hono

Out-of-order HTML streaming

Closed this issue · 2 comments

What is the feature you are proposing?

A hono utility to output out-of-order HTML streams.

e.g. A header and footer element are streamed to the client. When some data in the backend is available, the main (i.e. middle) content of the page is rendered.

Hono does not yet support streaming HTML in any capacity, but this doesn't seem especially difficult to add. Out of order streaming itself is not traditionally supported by most frameworks, but it could be cool for Hono to be the front-runner in this domain.

Issues

Doing this strictly in the backend isn't yet possible without wrapping the entire page in a declarative shadow dom. This has other implications. Other frameworks do this through injecting small JS snippets, which we may want to explore.

I have a snippet here of one such implementation, but we can arguably get a cleaner API and implementation without resorting to onload events.

Hi @EmNudge

Hono JSX has a Suspense. Is this not enough?

https://hono.dev/guides/jsx#suspense

It's definitely close enough! I didn't realize all html-related streaming behavior was bundled in the JSX section.