Closed
Description
What problem does this feature solve?
Current server rendering is a bit limiting and difficult to extend because it does many things at once.
It creates a full VNode tree for an input, resolves teleports and returns a string.
In order to extend it (for example to await on special hook) you'll have to duplicate all that logic in your custom renderer.
Maybe it'll be beneficial to split resolving VNodes and rendering into separate actions?
This would also resolve an issue with runtime ssr helpers and renderToStream
and allow both renderToStream
and renderToString
utilize the same buffer, resulting in a simpler code (rendering is bound to buffer constructor in renderToStream
pull request).
What does the proposed API look like?
const ssrContext = getSSRcontext(input)
const { buffer } = ssrContext // async buffer, an array of nested buffers of strings and promises
const stream = bufferToStream(buffer)
const string = await bufferToString(buffer)
await resolveBuffer(buffer) // wait for VNode and Teleports to become ready
ssrContext.vnode // collect extra data from nodes
ssrContext.teleports // decide how to deal with teleports
Or alternatively pass an entire context for rendering to automatically resolve teleports:
const ssrContext = getSSRcontext(input)
const stream = contextToStream(ssrContext)
const string = await contextToString(ssrContext)
Metadata
Metadata
Assignees
Labels
No labels