You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 6e9db79
Browse filesBrowse the repository at this point in the historyBrowse files
authored
docs: teach router mutations through actions; formAction as the form add-on (#1662)
* docs: drop deprecated router action/useAction mentions from guides
Old names stay only in the migration guide and the API reference.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CLHVghj7oAvSMqnq9WRKdv
* docs: sweep router pages for form action wording
Rename the 'Mutate with actions' and 'Post a form through a router action'
headings (and their anchors) to say form actions, call the router's wrapper a
form action wherever bare 'action' meant it, and keep 'action' for the core
solid-js primitive. Mirror the updated revalidate JSDoc in the respond,
reload and redirect reference pages.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CLHVghj7oAvSMqnq9WRKdv
* ci: apply automated fixes
* docs: sync generated reference with solid next
Add dispositions for createDeferred (new Reactivity page) and
ServerFunctionsSend (folded into configureServerFunctionsClient), then
regenerate the reference against solid next b0ad1df5.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CLHVghj7oAvSMqnq9WRKdv
* docs: teach router mutations through actions, form actions as the add-on
The data page now starts mutations from a server function called inside a
core action (the mounted router applies its revalidation and redirect),
with optimistic writes and failures shown on that path. formAction follows
as the layer a <form> adds: the no-JavaScript URL, aria-busy,
useSubmissions, .onSubmit and .with().
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CLHVghj7oAvSMqnq9WRKdv
---------
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Copy file name to clipboardExpand all lines: src/routes/(2)concepts/(5)mutations.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -363,5 +363,5 @@ Remove the call and assert after the action's promise resolves.
363
363
-[Forms](/guides/forms): the same actions behind a `<form>`, with progressive enhancement, validation, and errors returned from the server.
364
364
-[Mutations and responses](/building-apps/server-functions/mutations-and-responses): writing `api.add` as a `"use server"` function and returning redirects, statuses, and safe errors.
365
365
-[Boundaries](/concepts/boundaries): where `Errored` catches the errors an action does not, and how an errored region recovers.
366
-
-[Data loading and mutations](/routing/solid-router/data): Solid Router's `action` and `query` add submissions, caching, and revalidation on top of these primitives.
366
+
-[Data loading and mutations](/routing/solid-router/data): with Solid Router mounted, the same actions call server functions and the router applies their revalidation and redirects; `query` adds caching and `formAction` adds forms.
367
367
-[State management](/guides/state-management): where the cart, the user, and the filter live, and why `createCart()` runs inside a provider.
Copy file name to clipboardExpand all lines: src/routes/(3)building-apps/(3)server-functions/(3)mutations-and-responses.mdx
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -223,10 +223,10 @@ Render `<form method="post" action={addToCartAction}>` and the form posts to the
223
223
The router marks the form `aria-busy` while it runs and, once it settles, records a submission whose `error` is the thrown envelope's value, which the [Forms guide](/guides/forms) reads to show messages next to the fields.
224
224
225
225
Keep the server function a named export and wrap it separately, as above, so a test or an API route can call `addToCart` without the form.
226
-
When the function exists only for the form, write the body inline, `formAction(async (form: FormData) => { "use server"; ... })`; the [Data loading and mutations](/routing/solid-router/data#mutate-with-actions) page uses that shape throughout, and the two behave the same.
226
+
When the function exists only for the form, write the body inline, `formAction(async (form: FormData) => { "use server"; ... })`; the two behave the same, and [Data loading and mutations](/routing/solid-router/data#add-a-form-with-formaction) shows both.
227
227
228
228
:::note[Which action]
229
-
`formAction` is from `@solidjs/router`; earlier releases called it `action`, and that name remains as a deprecated alias.
229
+
`formAction` is from `@solidjs/router`.
230
230
`solid-js` exports its own [`action`](/reference/solid-js/lifecycle-actions/action), which runs a generator as a reactive transaction and has no URL; [Mutations](/concepts/mutations) covers it.
Copy file name to clipboardExpand all lines: src/routes/(3)building-apps/(3)server-functions/(5)progressive-enhancement.mdx
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,9 +13,9 @@ The server-function runtime recognizes a browser form post at that URL, decodes
13
13
14
14
Application code reaches this through a router.
15
15
Solid Router's `formAction()` wraps the server function in a value that serializes to that URL, so the same `<form action={...}>` works before hydration and is taken over by the router after it.
16
-
Most applications need only the [router action](#post-a-form-through-a-router-action) section; the rest of the page is the transport underneath, for forms outside the router and for integrations that build their own form helpers.
16
+
Most applications need only the [form action](#post-a-form-through-a-form-action) section; the rest of the page is the transport underneath, for forms outside the router and for integrations that build their own form helpers.
17
17
18
-
## Post a form through a router action
18
+
## Post a form through a form action
19
19
20
20
Declare a server function that takes one `FormData` argument, and wrap it with `formAction` from `@solidjs/router`:
Copy file name to clipboardExpand all lines: src/routes/(3)building-apps/(3)server-functions/(7)durable-generation.mdx
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,17 +10,17 @@ It is the wrong one for a summary of a forty-message order dispute: the shopper
10
10
11
11
The difference is who owns the generation.
12
12
In the streaming guide the request owns it, and the reactive graph cancels it.
13
-
On this page a job on the server owns it: an action starts the job and returns, the job writes the reply into storage as the model produces it, and every page that shows the reply reads what is stored through a live source.
13
+
On this page a job on the server owns it: a server function starts the job and returns, the job writes the reply into storage as the model produces it, and every page that shows the reply reads what is stored through a live source.
14
14
Pick the request-scoped shape when the reader is the only consumer and an abandoned answer has no value; pick this shape when the reply must finish without its reader, be found again on reload, or be read from more than one tab.
15
15
16
16
Two deliveries are shown.
17
17
The client-owned one sends the reply as data through [`live()`](/reference/solid-web/server-functions/live) and renders it in the browser.
18
18
The server-owned one renders the whole thread on the server as a live server component, which is the shape of the `chat` example in the Solid repository; server components are an experimental preview, and that section says so.
19
-
The job, the storage, and the actions are the same in both.
19
+
The job, the storage, and the server functions are the same in both.
20
20
21
21
## The job
22
22
23
-
Three modules carry the shape: a store the job writes into, a registry of running jobs that no request owns, and the actions that start and stop one.
23
+
Three modules carry the shape: a store the job writes into, a registry of running jobs that no request owns, and the server functions that start and stop one.
24
24
25
25
The store keeps each reply and tells watchers when it changes:
26
26
@@ -115,7 +115,7 @@ The signal it receives is the job's own, not a request's: Stop aborts it, and no
115
115
A reply that fails keeps the text that had arrived, with the reason beside it; a reply that was stopped keeps its text and says so.
116
116
Write at most every few tens of milliseconds when the model is fast, as the example does, since every write wakes every watcher.
117
117
118
-
The actions start and stop a job and return at once:
118
+
The server functions start and stop a job and return at once:
`sendMessage` stores the shopper's message and an empty reply with status `generating`, starts the job, and returns.
144
144
The response closes while the job is still writing; the server-function runtime does not dispose work a function started, so the job runs to its end whether or not anyone is watching.
145
145
`threads.append` is the thread half of the store, which keeps the message list and the history the model reads; the `chat` example's `db.send` is one.
146
-
`stopReply` is a Solid Router [form action](/routing/solid-router/data#mutate-with-actions), so the Stop button works as a form before JavaScript has loaded.
146
+
`stopReply` is a Solid Router [form action](/routing/solid-router/data#add-a-form-with-formaction), so the Stop button works as a form before JavaScript has loaded.
147
147
`sendMessage` is a plain server function the composer calls from code; the mounted router applies its response, revalidation included, the same way it does for a form.
148
148
149
149
:::caution[An orphan is a fact, not a hang]
@@ -398,7 +398,7 @@ Give the job an `AbortController` the registry owns, and pass `request.signal` o
398
398
399
399
### Stop does nothing
400
400
401
-
The Stop action aborted a controller the job was not reading, or the job was started by a server that has since restarted.
401
+
The Stop button aborted a controller the job was not reading, or the job was started by a server that has since restarted.
402
402
Check that `generations.start` passes `abort.signal` to the model call, and that the store marks orphaned replies `failed` on load.
Copy file name to clipboardExpand all lines: src/routes/(4)routing/(1)solid-router/(0)index.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -235,5 +235,5 @@ Read these in order if you are new to Solid Router, or jump to the one you need:
235
235
2.[Route definitions](/routing/solid-router/route-definitions): path patterns, parameter filters, route metadata, lazy subtrees, and the file-system manifest.
236
236
3.[Nested routes and layouts](/routing/solid-router/nested-routes): an account section with its own frame that stays mounted while its pages change.
237
237
4.[Navigation and typed paths](/routing/solid-router/navigation): `paths`, `useNavigate`, search parameters with a schema, active and pending links, and leave guards.
238
-
5.[Data loading and mutations](/routing/solid-router/data): `preload`, `query`, `formAction`, optimistic updates, and what revalidates after a mutation.
238
+
5.[Data loading and mutations](/routing/solid-router/data): `preload`, `query`, mutations through server functions and actions, forms with `formAction`, optimistic updates, and what revalidates.
239
239
6.[Server rendering and hydration](/routing/solid-router/server-rendering): what the server adds when the app renders there, and how a mutation returns fresh data in one round trip.
Copy file name to clipboardExpand all lines: src/routes/(4)routing/(1)solid-router/(4)navigation.mdx
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -100,7 +100,7 @@ A number moves through history: `navigate(-1)` is back.
100
100
101
101
:::tip[Let the server decide where to go]
102
102
A mutation that ends in a navigation does not need `useNavigate` at all.
103
-
Return `redirect(paths.account.orders(id))` from the server function or action and the router navigates when the response arrives, in the same update as the revalidation; the [Data](/routing/solid-router/data#what-revalidates-after-a-mutation) page covers that path.
103
+
Return `redirect(paths.account.orders(id))` from the server function and the router navigates when the response arrives, in the same update as the revalidation; the [Data](/routing/solid-router/data#what-revalidates-after-a-mutation) page covers that path.
104
104
:::
105
105
106
106
## Read the location
@@ -306,6 +306,6 @@ Add the schema with a transform to `Number`, and read with `useSearchParams(Rout
306
306
## Next steps
307
307
308
308
-[Nested routes and layouts](/routing/solid-router/nested-routes): where section navigation lives and what stays mounted across links.
309
-
-[Data loading and mutations](/routing/solid-router/data): how links preload ahead of a click, and `redirect()` from an action.
309
+
-[Data loading and mutations](/routing/solid-router/data): how links preload ahead of a click, and `redirect()` from a mutation.
310
310
-[State management](/guides/state-management#state-in-the-url): which page state belongs in the URL at all.
311
311
-[Navigation API reference](/reference/solid-router/navigation): signatures for every primitive on this page.
0 commit comments