Skip to content

Single flight at router mount; rename action to formAction - #688

Open
ryansolid wants to merge 2 commits into
nextfrom
claude/project-thread-257vck
Open

ryansolid wants to merge 2 commits into
nextfrom
claude/project-thread-257vck

Conversation

@ryansolid

@ryansolid ryansolid commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

Before: the router's single flight (applying X-Revalidate keys, redirect(), reload() and flight data from a server function response) was installed only when the first router action was created. A server function called straight from an event handler got none of it unless it went through useAction. The router's action also shared its name with solid-js's action primitive.

After: a mounted router subscribes to single flight itself (unless singleFlight={false}), so any server function call gets revalidation and redirects. The router's action is renamed formAction (type FormAction), the form layer: submissions, aria-busy, no-JS posts and .with(). action and Action stay as deprecated aliases with a one-time dev warning. useAction is deprecated with no replacement; outside a form, call the server function or a core action directly. query and liveQuery keep their names.

How:

  • The flight-data consumer moves from data/action.ts into data/query.ts, and the Router calls it at mount. The routing.ts register/provide rendezvous is removed.
  • Query reads, the consumer and actions share one redirect/revalidation helper (applyServerResponse). As a result, action redirects now resolve against the router base the same way query redirects do.
  • src/data/deprecated.ts holds the action alias; useAction warns once in dev.
  • README and tests are updated, and two patch changesets are added.

Size (entry chunk, brotli, Vite production build through the solid entry):

App Before After
Plain router, fetch query 21,694 B 21,663 B
Query + server function, no actions 21,668 B 21,656 B
Plus a form action 23,203 B 23,104 B

Tests: npm test (710 client tests, 96 server tests, type tests) passes and pnpm build (fs gate) passes. A new test checks that a router with no actions subscribes at mount and that singleFlight: false never subscribes.

🤖 Generated with Claude Code

https://claude.ai/code/session_01CLHVghj7oAvSMqnq9WRKdv

@ryansolid ryansolid self-assigned this Oct 19, 2026
@changeset-bot

changeset-bot Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 7ec5ea1

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

This PR includes changesets to release 1 package
Name Type
@solidjs/router 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

@ryansolid
ryansolid marked this pull request as ready for review October 19, 2026 21:14
The flight-data consumer moves from the action module into query.ts and
the Router subscribes it at mount (unless singleFlight={false}), so a
server function called straight from an event handler gets X-Revalidate,
redirect and flight data applied without an action. Query reads, the
consumer and actions share one redirect/revalidation helper
(applyServerResponse), and the routing.ts rendezvous is gone, so this
costs nothing: HN-style bundle (query + server fn, no actions) is 12 B
brotli smaller, an app with actions 99 B smaller.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CLHVghj7oAvSMqnq9WRKdv
The router's action is the form layer (submissions, aria-busy, no-JS
posts, .with()), and `action` is solid-js's own primitive, so the router
export becomes `formAction` (type `FormAction`). `action` and `Action`
stay as deprecated aliases with a one-time dev warning. `useAction` is
deprecated with no replacement: the router now applies revalidation and
redirects on any server function call, so outside a form the server
function (or a core action) is called directly. `query` and `liveQuery`
keep their names.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CLHVghj7oAvSMqnq9WRKdv
@ryansolid
ryansolid force-pushed the claude/project-thread-257vck branch from 03739af to 7ec5ea1 Compare October 20, 2026 07:19
@ryansolid ryansolid changed the title Rename data APIs to routeQuery / routeAction (deprecated aliases kept) Single flight at router mount; rename action to formAction Oct 20, 2026
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.

2 participants