Skip to content

Router seeding from the server: routers module, announceRoutes, drop filesystem-routing - #4

Merged
ryansolid merged 4 commits into
mainfrom
router-announce
Sep 6, 2026
Merged

Router seeding from the server: routers module, announceRoutes, drop filesystem-routing#4
ryansolid merged 4 commits into
mainfrom
router-announce

Conversation

@ryansolid

Copy link
Copy Markdown
Member

Replaces build-time route-directory scanning with the server declaring its own pages.

Why. fileRoutePages walked src/routes at build time and re-derived filesystem-routing's path rules — a copy of another package's semantics, blind to routes defined in code (Solid Router config routes, TanStack Router), and useless to a crawl that never sees the project's disk (the CLI against a running server). The thing that actually knows which pages exist is the router the app built for the request, and the crawler already has the channel for a server to say so: the x-prerender hint header.

prerender-crawler/routers (no Node imports — for application server code):

  • tanstackRouterPages(router) — from a TanStack instance's public routesByPath (one core for React/Solid/Vue flavors). Skips $ segments (params, splats, {-$optional}) and layouts without an index.
  • solidRouterPages(router | routes, { base? }) — walks a Solid Router 2 createRouter instance or definition tree. Leaves and indexes, aliases expanded, pathless layouts joined through, :param/:opt?/*splat skipped; lazy children left to link crawling (enumerating them would load modules during a render).
  • announcePages(request, headers, paths) — writes the header only for the crawler's request.

Both helpers are tested against real @tanstack/router-core and @solidjs/router instances (dev deps), so drift in either shape shows up in our CI.

@solidjs/prerender: announceRoutes(Router) — one line in the app root; reads the ambient request event on the server, no-op in the browser.

Removed: fileRoutePages, staticRoutePaths, the plugin's fileRoutes option, and the filesystem-routing peer.

Verified: 65 crawler + 23 solid tests; example build renders the same 5 pages; and with --no-links the CLI renders exactly / + the announced /posts (dynamic /posts/:slug correctly left to links), proving the header path end to end.

Made with Cursor

ryansolid and others added 4 commits September 6, 2026 00:23
prerender-crawler/routers (no Node imports, for application server code):
tanstackRouterPages(router) reads a TanStack instance's routesByPath;
solidRouterPages(router | routes) walks a Solid Router 2 definition tree;
announcePages(request, headers, paths) puts them on the hint header when
the request is the crawler's. Tested against real @tanstack/router-core
and @solidjs/router instances (dev deps) so drift in either shape shows
up here first.

Co-authored-by: Cursor <cursoragent@cursor.com>
fileRoutePages, staticRoutePaths, and the plugin's fileRoutes option walked
a route directory at build time and re-derived its path rules — a copy of
another package's semantics, blind to routes defined in code, and useless
to a crawl that never sees the project's disk (the CLI against a running
server). The server's router announcing its pages on the hint header
replaces all of it. filesystem-routing is no longer a peer; the router
packages join as dev deps for the routers tests.

Co-authored-by: Cursor <cursoragent@cursor.com>
Server half reads the ambient request event and, for the crawler's
request, writes the router's static pages to the response's hint header;
client half is a no-op. The example root calls it.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@socket-security

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Added@​tanstack/​router-core@​1.171.27971007897100

View full report

@ryansolid
ryansolid merged commit a11368a into main Sep 6, 2026
4 checks passed
@ryansolid
ryansolid deleted the router-announce branch September 6, 2026 07:25
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