Skip to content

kettanaito/rsc-frameworkless

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RSC Frameworkless

Getting started

npm install
npm start

RSC

  1. lib/index.js loads the given React component using vite.ssrLoadModule(). This evaluates the module server-side and returns the component. This uses the Vite config you have to stay consistent.
  2. lib/index.js then has GET /payload endpoint responsible for generating the RSC Payload (0:['$', 'div', null]) from the component tree and sending it to the client during hydration.
  3. The client (lib/hydrate.js) requests the RSC Payload (makes a GET /payload request) during hydration to render the component tree.

This pipeline has no SSR so the initial HTML is empty, causing the hydration errors. Those have been disabled by not relying on .hydrateRoot() but instead using .createRoot(). It'd be great to introduce SSR as well and use .hydrateRoot() properly.

About

A frameworkless, barebones example of RSC usage.

Resources

Stars

Watchers

Forks