Skip to content

[SSR] Async renderToString to allow data-prefetching #11

Closed
@Akryum

Description

@Akryum

This would allow for automatic data prefetching (for example with apollo) on the server.

Ideas:

  • waitCounter = 0
  • mount the App and render the whole component tree
  • user/lib code can hook into renderToString with this.waitForPrefetch() (waitCounter++)
  • if waitCounter is 0, resolve renderToString
  • else, we wait for user/lib code that should call this.prefetchDone() after fetching data
    • we re-render the component
    • eventually code in children can call this.waitForPrefetch() again
    • then waitCounter--
    • then if waitCounter is 0 we resolve renderToString
  • a re-render could trigger new this.waitForPrefetch() (maybe make this parametrable, like maxReRenders)
  • <NoSSR> component prevents both server-side render and async prefetching
  • some way of skipping a component (and its children) only for async prefetching, like a skipPrefetch () { return this.myProp } option?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions