Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change SSR to render to stream instead of to string. #3194

Open
danielyanghansen opened this issue Jan 28, 2023 · 0 comments
Open

Change SSR to render to stream instead of to string. #3194

danielyanghansen opened this issue Jan 28, 2023 · 0 comments
Assignees
Labels
enhancement Pull requests that make or issues that suggest enhancements, instead of just purely new features

Comments

@danielyanghansen
Copy link
Member

Currently, the SSR renders components to a HTML string before it responds with anything.

renderToString() is a fully blocking operation and this can take a while (a few seconds), which has a couple of downsides:

  • Relatively bad perceived performance (compared to CSR and other types of SSR, which emit the "blank loading page")
  • Since the black magic of SEO seems to be somewhat impatient, too slow SSR might lead to a timeout for various web crawlers. ...which is bad for us

renderToNodeStream() is now deprecated, so renderToPipeableStream() seems like the only choice here.

A few pitfalls to look out for / Points to remember:

  • Client needs to re-hydrate with each new chunk that is sent
  • Since all types of rendering are blocking, make sure that Worker Threads are used instead of the Main Thread as much as possible
  • Make sure this doesn't break react-prepare

Helpful links:

(This might be be able to Fix up in our issues with Helmet)

@danielyanghansen danielyanghansen added the enhancement Pull requests that make or issues that suggest enhancements, instead of just purely new features label Jan 28, 2023
@danielyanghansen danielyanghansen self-assigned this Jan 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Pull requests that make or issues that suggest enhancements, instead of just purely new features
Projects
None yet
Development

No branches or pull requests

1 participant