Repository navigation
feat(templates): render every Html document component (Html.Meta, Html.Scripts, Html.ScrollRestoration) - #1
Merged
Merged
Conversation
Prepares the templates for the @rangojs/router release that groups the document components under `Html` (rangojs/rango#937), which removes `MetaTags`. Every template's Document now renders the full shell: `Html.Meta` and `Html.Scripts` in <head>, `Html.Scripts position="body"` at the top of <body>, and `Html.ScrollRestoration` at its end, so the Meta and Script handles and back/forward scroll restoration work out of the box. The Document's accessibility focus on route change now passes `preventScroll: true`. A plain `focus()` scrolled to #main-content, so every new navigation landed at scrollY 117 instead of the top, and it would fight the restored position. Template READMEs describe the three components. Not mergeable until that router release is on npm: the template pins (^0.12.3) resolve a router with no `Html`. Bump the pins in the same change.
This was referenced Sep 28, 2026
Template pins move to the router release that ships the Html namespace (0.17.0); the bundled pin is create-rango's offline fallback. The lockfile takes @vitejs/plugin-rsc 0.5.35, which router 0.17.0 requires. create-rango 0.2.3 publishes these templates.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
@rangojs/router 0.17.0, which includes rangojs/rango#937, is published; this PR moves the templates to it and republishes create-rango as 0.2.3.
Problem
rangojs/rango#937 groups the router's document components under one namespace and removes the old names:
MetaTagsbecomesHtml.Meta,ScriptsbecomesHtml.Scripts,ScrollRestorationbecomesHtml.ScrollRestoration. Every template'sDocumentimportsMetaTags, so a template scaffolded against that release fails to compile.create-rango rewrites the router pin to the registry's
latestat scaffold time. So from the moment that router release is published, every new scaffold breaks until create-rango is republished with this change.The templates also rendered only
MetaTags: theScripthandle had nowhere to render, and back/forward did not restore scroll.Before / after
A scaffolded app can now push
ctx.use(Script)({ id, children })from any handler without touching the Document, and back/forward returns to the scroll position the user left.Code change
templates/{basic,basic-js,cloudflare,vercel}/src/components/Document.{tsx,jsx}: the fullHtmlshell above.contentRef.current?.focus({ preventScroll: true }). A plainfocus()scrolled to#main-content, so every new navigation landed atscrollY117 instead of the top, and it would fight the restored position. Focus still moves for screen readers; the router owns the scroll.templates/*/README.md: the Document line names the three components and what each renders.Test plan
Run against a router tarball packed from rangojs/rango main (
231fe107, includes #937), wired in through a temporarypnpm-workspace.yamloverridesentry (not committed):check:generated,typecheck,lint,format,build,test:unit, create-rangotest:smoke.test:runtime: all 4 templates, dev + production (asserts the<title>rendered byHtml.Meta)./about(lands at 0), back (restores 2000), forward (0). With the oldfocus(), push and forward land at 117.Scriptpushes in basic's HomePage): both render in the right element and execute, dev + production.MetaTagsDocument against the new router fails typecheck withTS2305 … no exported member 'MetaTags'.pnpm run check:check:generated, typecheck, lint, format, build, unit, create-rango smoke,test:pack(all 4 templates scaffold + install + build from the packed tarball, vercel runtime, basic production server),test:runtime(4 templates, dev + production).Release checklist
^0.12.3->^0.17.0(the bundled pin is create-rango's offline fallback).@vitejs/plugin-rsc0.5.34 -> 0.5.35, which router 0.17.0 requires (pnpm peers checkclean).pnpm run check, includingtest:pack.v0.2.3.Notes
231fe107.