Skip to content

Async rendering #321

@GauBen

Description

@GauBen

As a developer
I want to write async JSX components on the server
In order to use functions I don't control

Notes

Provide any useful information (Technical, Design)

https://www.graalvm.org/latest/reference-manual/js/JavaInteroperability/#promises

Here is an example of an async component:

async function Comp() {
  const value = await Promise.resolve(42);
  return <strong>{value}</strong>
}

The goal of this story is to be able to render it in a JSX view/template on the server.

https://react.dev/reference/react-dom/server/renderToString#migrating-from-rendertostring-to-a-streaming-method-on-the-server

Technical notes

There are two levels of async support:

  • Easy mode: only allow the template/view function to be async, and await it before piping the result to renderToString
  • Hard mode: figure out a way to use renderToStream and reconstruct the HTML tree

Metadata

Metadata

Assignees

No one assigned

    Labels

    devexTicket that can be managed by developer advocate without dev team

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions