Skip to content

Commit c7c4a86

Browse files
committed
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) <[email protected]> Claude-Session: https://claude.ai/code/session_01CLHVghj7oAvSMqnq9WRKdv
1 parent 1f46b00 commit c7c4a86

7 files changed

Lines changed: 147 additions & 109 deletions

File tree

‎src/routes/(2)concepts/(5)mutations.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,5 +363,5 @@ Remove the call and assert after the action's promise resolves.
363363
- [Forms](/guides/forms): the same actions behind a `<form>`, with progressive enhancement, validation, and errors returned from the server.
364364
- [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.
365365
- [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 `formAction` 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.
367367
- [State management](/guides/state-management): where the cart, the user, and the filter live, and why `createCart()` runs inside a provider.

‎src/routes/(3)building-apps/(3)server-functions/(3)mutations-and-responses.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ Render `<form method="post" action={addToCartAction}>` and the form posts to the
223223
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.
224224

225225
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-form-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.
227227

228228
:::note[Which action]
229229
`formAction` is from `@solidjs/router`.

‎src/routes/(3)building-apps/(3)server-functions/(7)durable-generation.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ export const stopReply = formAction(async (replyId: string) => {
143143
`sendMessage` stores the shopper's message and an empty reply with status `generating`, starts the job, and returns.
144144
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.
145145
`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-form-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.
147147
`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.
148148

149149
:::caution[An orphan is a fact, not a hang]

‎src/routes/(4)routing/(1)solid-router/(0)index.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,5 +235,5 @@ Read these in order if you are new to Solid Router, or jump to the one you need:
235235
2. [Route definitions](/routing/solid-router/route-definitions): path patterns, parameter filters, route metadata, lazy subtrees, and the file-system manifest.
236236
3. [Nested routes and layouts](/routing/solid-router/nested-routes): an account section with its own frame that stays mounted while its pages change.
237237
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.
239239
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.

0 commit comments

Comments
 (0)