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

poc: add support for custom RSC in preview/delivery mode #833

Draft
wants to merge 2 commits into
base: development
Choose a base branch
from

Conversation

chasepoirier
Copy link
Contributor

Purpose

Explore what it would take to fully support customer components that are React Server Components in Studio.

Approach

This approach extends off of the work to make our ExperienceRoot a server component so that we can understand where limitations will be and what work needs to be done next for the overall initiative.

Findings are as follows:

  • The entityStore needs to be used by both client and server components, but we can only pass plain JS objects between client and server components, not functions or classes. We'll need a way to deserialized/serialize the entityStore so it can be used by both sides.
  • When a custom defines components, that component definition will need to be supplied to both the client and server side of our SDK. For example, if a custom defines their custom components in a server component, the componentRegistry will only know about the custom components on the server. We need a way to have the componentRegistry be available on both client and server. This runs into similar caveats above where we can't pass customer components (functions)
  • We need to update the build script of our VisualEditor pkg if we want to make at least the VisualEditorRoot a server component. Right now the build script bundles all the code into one file so client code is mixed with server code.
  • We'll need a way to pre-render server components from the PreviewDeliveryRoot.tsx and VisualEditorRoot.tsx so that they can be passed as props to the client side CompositionBlock.tsx components. This is where having the component definition option of .isRSC: true comes into play so server components are pre-rendered.

@chasepoirier chasepoirier requested review from a team as code owners November 8, 2024 15:25
Copy link

vercel bot commented Nov 8, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
nextjs-marketing-demo-bug-test ✅ Ready (Inspect) Visit Preview Nov 8, 2024 3:29pm
3 Skipped Deployments
Name Status Preview Updated (UTC)
experience-builder-test-app ⬜️ Ignored (Inspect) Nov 8, 2024 3:29pm
studio-nextjs-marketing-demo ⬜️ Ignored (Inspect) Nov 8, 2024 3:29pm
studio-react-vite-template ⬜️ Ignored (Inspect) Nov 8, 2024 3:29pm

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