Skip to content

[lexical-headless] Feature: @lexical/headless/dom module for easier SSR - #7833

Merged
etrepum merged 8 commits into
meta:mainfrom
etrepum:headless-dom
Sep 24, 2025
Merged

etrepum merged 8 commits into
meta:mainfrom
etrepum:headless-dom

Conversation

@etrepum

@etrepum etrepum commented Sep 19, 2025 •

Copy link
Copy Markdown
Collaborator

Description

This adds a new entrypoint to @lexical/headless at @lexical/headless/dom that uses conditional exports so that importing it from node brings in a happy-dom implementation of withDOM and importing it from the browser brings in a trivial withDOM = (f) => f(window) implementation. This is using the same sort of trick that react-dom uses to have separate implementations for react-server and everything else.

RE #4960 - Not closing this one because it could use examples and maybe some framework support. Could even implement hydration either with JSON (like react with some json blob on the page) or HTML (if the user is careful to have an exportDOM/importDOM that round-trips). A react-server conditional export somewhere in @lexical/react would possibly make sense for that use case.

Closes #3616

Test plan

Adds unit tests. Manually tested that adding withDOM to the playground brings in the trivial browser version.

Follow-up work would be to add examples and more usage, but those are a lot easier to write once there is a version published to npm (at least a nightly).

@vercel

vercel Bot commented Sep 19, 2025 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
lexical Ready Ready Preview Comment Sep 24, 2025 3:43am
lexical-playground Ready Ready Preview Comment Sep 24, 2025 3:43am

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 19, 2025
@etrepum etrepum changed the title [WIP][lexical-headless] Feature: @lexical/headless/dom module for easier SSR [lexical-headless] Feature: @lexical/headless/dom module for easier SSR Sep 20, 2025
@etrepum
etrepum marked this pull request as ready for review September 20, 2025 17:30
ivailop7
ivailop7 previously approved these changes Sep 22, 2025
@etrepum

etrepum commented Sep 22, 2025

Copy link
Copy Markdown
Collaborator Author

I will wait to merge this until after #7706 to avoid approval and merge conflict churn on that larger PR

@etrepum

etrepum commented Sep 24, 2025

Copy link
Copy Markdown
Collaborator Author

@ivailop7 this needs a re-approval after fixing the merge conflict

@etrepum
etrepum added this pull request to the merge queue Sep 24, 2025
@ivailop7

Copy link
Copy Markdown
Collaborator

@ivailop7 this needs a re-approval after fixing the merge conflict

Done!

Merged via the queue into meta:main with commit b960c83 Sep 24, 2025
@etrepum
etrepum deleted the headless-dom branch September 24, 2025 14:05
This was referenced Sep 25, 2025

This branch was successfully deployed

2 active deployments
Preview – lexical-playground — 7e8596fb Deployed Sep 24, 2025 by vercel[bot]
Preview – lexical — 7e8596fb Deployed Sep 24, 2025 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. extended-tests Run extended e2e tests on a PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Can't use generateHtmlFromNodes correctly for SSR

2 participants