Server side rendering (SSR)
One of the most important and difficult to implement part of SSR is data-fetching. Farfetched aims to make it smooth and easy.
Farfetched is based on Effector, that have an excellent support of SSR, so you can handle data-fetching easily if you follow some simple rules:
- do not start fetching in render-cycle
- do use Fork API in Effector and make sure that your application has correct SIDs
- do use Effector operators to express your control flow
That is it, just start your application on server and wait for all computation finished:
ts
async function renderApp() {
const scope = fork();
await allSettled(appStarted, { scope });
const html = renderUI(scope);
return html;
}