Skip to content

feat: add a PageHead that renders its tags as elements - #3

Open
raajnadar wants to merge 1 commit into
mainfrom
feat/web-runtime-beta
Open

raajnadar wants to merge 1 commit into
mainfrom
feat/web-runtime-beta

Conversation

@raajnadar

Copy link
Copy Markdown
Member

Run the libraries on a second web runtime

This PR prepares the packages for a React 19 web app that has no Expo
Router and no react-native-web. It lands in steps, one commit each.

1. @rootnative/seo/web: a PageHead that a server can render

PageHead from /dom writes the head in an effect. An effect never runs
on a server, so a page that a server renders, or a build step prerenders,
has no head in its HTML.

The new entry renders the same toHeadTags records as <title>, <meta>
and <link> elements. React 19 moves them into <head> on the server and
in the browser. The JSON-LD stays in the page body.

  • Same props as the /dom PageHead: PageMeta, site, active.
  • It takes the <title> and the page-slot tags of the HTML template out of
    the head while the page is on, and puts them back when it goes.
  • React doesn't merge two heads. A screen that stays mounted behind another
    must pass active={false}. /dom stays the choice for an app that stacks
    screens with no active prop.
  • Native renders null.

No breaking change. No peer range moves.

Tests

  • web project: the head matches the /dom head for one PageMeta, tags
    change and go on unmount, template tags go and come back, active={false}
    renders no tag.
  • native project: renderToString has the title, the description, the
    canonical link, the hreflang links and the JSON-LD.

To check on CI

  • api:check: I added ./web to api-surface.json by hand.
  • The build of the new entry.

Next steps in this PR

  • The example app on Vite, beside the Expo app.
  • The web-only right-to-left code of Slider, TextField,
    LinearProgress and Carousel.

This branch has not been deployed

No deployments
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