Skip to content

fix: restore routerLoad argument to createHandler#2228

Merged
brenelz merged 1 commit into
mainfrom
fix-2221-restore-routerload
Jul 22, 2026
Merged

fix: restore routerLoad argument to createHandler#2228
brenelz merged 1 commit into
mainfrom
fix-2221-restore-routerload

Conversation

@brenelz

@brenelz brenelz commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Summary

Restores the optional routerLoad third argument to createHandler, which was accidentally dropped in the v2 rewrite (#1942).

routerLoad was introduced in #1840 to enable TanStack Router SSR — it primes the router store on the server before rendering. The client half of that integration (StartClientTanstack) survived the rewrite, but the server half didn't, so any v2 app following the with-tanstack-router template pattern (createHandler(fn, undefined, routerLoad)) returns HTTP 500 with TypeError: Cannot read properties of undefined from the uninitialized router store. The docs (create-handler.mdx) still document the parameter.

Fixes #2221

Changes

  • createHandler (server + SPA variants) accepts routerLoad?: (event: FetchEvent) => Promise<void> again and threads it through createBaseHandler.
  • It's invoked just before createPageEvent, so it only runs for page renders. This is a slight narrowing from v1, where it ran at the top of provideRequestEvent for every request including API routes — the hook exists to prime the router store for SSR, so running it for non-page requests was wasted work.

Verification

Tested with a fixture app based on the original with-tanstack-router example (code-based routes, no router-plugin codegen), on a fresh server each time since the module-level router singleton retains state across hot reloads:

  • Without this fix: fresh server → HTTP 500, TypeErrors from the uninitialized router store (dev).
  • With this fix: HTTP 200 in dev and production build, route loader data rendered server-side, no console errors, client-side navigation works after hydration.
  • tsc --noEmit passes; unit test suite unchanged (the one pre-existing fetchEvent.spec failure reproduces identically on main).

🤖 Generated with Claude Code

The optional 3rd argument to createHandler, introduced in #1840 to
enable TanStack Router SSR, was accidentally dropped in the v2
rewrite (#1942). The client half (StartClientTanstack) survived, so
apps using the with-tanstack-router pattern crashed with a 500 from
an uninitialized router store.

Restores routerLoad on both createHandler variants and threads it
through createBaseHandler, invoked before createPageEvent so it only
runs for page renders (not server functions or API routes).

Fixes #2221

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@netlify

netlify Bot commented Jul 22, 2026

Copy link
Copy Markdown

Deploy Preview for solid-start-landing-page ready!

Name Link
🔨 Latest commit 00d960b
🔍 Latest deploy log https://app.netlify.com/projects/solid-start-landing-page/deploys/6a60b7c4cec82000089df027
😎 Deploy Preview https://deploy-preview-2228--solid-start-landing-page.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@changeset-bot

changeset-bot Bot commented Jul 22, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 00d960b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@solidjs/start Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Jul 22, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@solidjs/start@2228

commit: 00d960b

@brenelz
brenelz merged commit 4e98ac0 into main Jul 22, 2026
10 checks passed
@brenelz
brenelz deleted the fix-2221-restore-routerload branch July 22, 2026 19:16
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.

[Bug?]: [v2] routerLoad (3rd createHandler argument) dropped during v2 rewrite — TanStack Router SSR returns HTTP 500

2 participants