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

Add RSC wrapper library to simplify server and client #10074

Merged
merged 2 commits into from
Jan 21, 2025
Merged

Conversation

devongovett
Copy link
Member

This adds a @parcel/rsc library which simplifies writing both the server and client portions of an RSC app by providing higher level methods that bring together all of the different libraries you need.

@parcel/rsc/server and @parcel/rsc/node include renderRequest and callAction functions using the web Request/Response objects, and node IncomingMessage/ServerResponse objects respectively. renderRequest checks the Accept header and returns either HTML or an RSC stream. callAction handles running actions from both client fetches and progressively enhanced forms.

@parcel/rsc/client includes a hydrate function that hydrates the document with the embedded RSC data, and returns an updateRoot function that can be used to update the page for client navigations. It accepts options to handle server actions, and reload the page during HMR. It also includes a fetchRSC function that wraps fetch to automatically handle serializing and deserializing via the RSC protocol.

@devongovett devongovett merged commit 7eae895 into v2 Jan 21, 2025
17 checks passed
@devongovett devongovett deleted the rsc-library branch January 21, 2025 00:10
devongovett added a commit to parcel-bundler/rsc-examples that referenced this pull request Jan 21, 2025
sebmarkbage pushed a commit to facebook/react that referenced this pull request Feb 4, 2025
This implements `findSourceMapURL` in react-server-dom-parcel, enabling
source maps for replayed server errors on the client. It utilizes a new
endpoint in the Parcel dev server that returns the source map for a
given bundle/file. The error overlay UI has also been updated to handle
these stacks. See parcel-bundler/parcel#10082

Also updated the fixture to the latest Parcel canary. A few APIs have
changed. We do have a higher level library wrapper now (`@parcel/rsc`
added in parcel-bundler/parcel#10074) but I left
the fixture using the lower level APIs directly here since it is easier
to see how react-server-dom-parcel is used.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant