Remix V2 Forms
/install remix-v2-forms
Remix v2 Forms & Mutations
Canonical mutation primitives for the @remix-run/react@^2 route-module
framework. A correct Remix v2 mutation is: a \x3CForm method="post"> (or
\x3Cfetcher.Form>), an action that parses request.formData() and returns
either redirect(...) or json(...), and UI that reads useActionData()
(or fetcher.data) for errors plus useNavigation() (or fetcher.state)
for pending state. Anything that bypasses this loop — fetch(), raw
\x3Cform>, e.preventDefault() + client state — silently sacrifices
revalidation, progressive enhancement, and race-safe transitions.
Quick Reference
\x3CForm> + action:
import { json, redirect, type ActionFunctionArgs } from "@remix-run/node";
import { Form, useActionData, useNavigation } from "@remix-run/react";
export async function action({ request }: ActionFunctionArgs) {
const form = await request.formData();
const email = String(form.get("email") ?? "");
if (!email.includes("@")) return json({ errors: { email: "Invalid" } }, { status: 400 });
await createUser({ email });
return redirect("/dashboard");
}
export default function Signup() {
const actionData = useActionData\x3Ctypeof action>();
const nav = useNavigation();
const busy = nav.state !== "idle" && nav.formAction === "/signup";
return (
\x3CForm method="post" replace>
\x3Cinput name="email" type="email" />
{actionData?.errors?.email ? \x3Cem>{actionData.errors.email}\x3C/em> : null}
\x3Cbutton disabled={busy}>{busy ? "Signing up..." : "Sign Up"}\x3C/button>
\x3C/Form>
);
}
Primitives
| Name | Purpose |
|---|---|
\x3CForm> from @remix-run/react |
Navigating, progressively-enhanced form that posts to a route action and triggers full-page revalidation |
\x3CForm navigate={false}> |
Shorthand for "post via fetcher; do not navigate." Equivalent to \x3Cfetcher.Form> without holding a fetcher ref — useful when you only need pending state, not a programmatic handle |
useFetcher() |
Non-navigating submission channel for inline mutations, list rows, popovers — same revalidation, no URL change |
useFetchers() |
Read-only array of all in-flight fetcher states across the app. Use for global pending indicators (top-bar loader) without prop drilling. No Form/submit/load methods on the returned items — just formData, state, etc. |
useNavigation() |
Observes page-level navigation; the source of truth for \x3CForm> pending state |
useSubmit() |
Programmatic submission (onChange autosave, keyboard shortcuts). Accepts HTMLFormElement, FormData, plain object (form-encoded), or plain object encoded as JSON via { encType: "application/json" } |
useActionData\x3Ctypeof action>() |
Read the most recent action result for the current route |
State transitions:
useNavigation().state:idle → submitting → loading → idlefor non-GET form submissions;idle → loading → idlefor GET navigation.useFetcher().state:idle → submitting → loading → idle.
Asymmetry: useNavigation skips submitting for GET navigations; useFetcher does NOT — only fetcher.load() skips it. \x3Cfetcher.Form method='get'> and fetcher.submit(..., {method:'get'}) both transition through submitting.
Key Patterns
\x3CForm> for navigation, useFetcher for in-place
\x3CForm> changes the URL, adds history, and revalidates all loaders.
useFetcher does the same revalidation but stays on the current URL.
Each useFetcher() call returns an independent submission channel, so
two rows submitting at once do not share pending state.
Intent pattern for multiple actions on one route
One action, switch on formData.get("intent"), distinct
\x3Cbutton name="intent" value="..."> per operation. Only the clicked
submit button's name=value lands in the body. See
references/intent-actions.md.
Optimistic UI from formData
fetcher.formData and navigation.formData are populated synchronously
on submit and cleared at idle. Read directly each render; never mirror
into local React state. See
references/optimistic-ui.md.
File uploads need encType="multipart/form-data"
Without it, request.formData() strips file data and you get the
filename string instead of a File. Parse with
unstable_parseMultipartFormData and a bounded upload handler. The
unstable_ prefix is permanent in v2. See
references/uploads.md.
Gates (decision sequencing)
Answer in order. Pass means the condition is true; pick the API on the same line and stop.
\x3CForm> vs useFetcher
- Does the URL need to change after the mutation (creating a record
and routing to
/records/:id, deleting and going back to a list, multi-step flow)?- Pass →
\x3CForm method="post">+redirect(...)from the action. Stop. - Fail → Step 2.
- Pass →
- Is this a mutation against a row, cell, toggle, or sub-section while
the user stays on the same page (favorite, like, increment quantity,
inline edit)?
- Pass →
useFetcher()with\x3Cfetcher.Form>. Stop. - Fail → Step 3.
- Pass →
- Is this loading data outside of normal navigation (popover content,
combobox results, prefetch)?
- Pass →
fetcher.load(href). Stop. - Fail → Default to
\x3CForm>. Navigation is the conservative choice — revalidation and history work out of the box.
- Pass →
Hard rule: never reach for fetch() or axios for in-app mutations
against your own Remix routes. That bypasses the action lifecycle and
skips loader revalidation.
useNavigation vs useFetcher.state for pending state
- Is the pending indicator global (page spinner in root, top-bar
loading bar)?
- Pass →
useNavigation()inroot.tsx(navigation.state !== "idle"). Stop. - Fail → Step 2.
- Pass →
- Was the mutation made with
useFetcher?- Pass → Use that fetcher's
fetcher.state.useNavigation()will NOT reflect fetcher activity. Stop. - Fail → Step 3.
- Pass → Use that fetcher's
- Is the indicator scoped to one row/button inside a list where each
row has its own fetcher?
- Pass → Use the per-row
fetcher.state(or look up by key viauseFetchers()) so other rows do not flicker. Stop. - Fail → Step 4.
- Pass → Use the per-row
- Is the indicator scoped to the form just submitted via
\x3CForm>?- Pass →
useNavigation()AND checknavigation.formAction === "/expected-path"so unrelated navigations don't trigger your local spinner. Stop. - Fail → Step 5.
- Pass →
- Need to render an optimistic value?
- Pass → Read
navigation.formData?.get("field")(page form) orfetcher.formData?.get("field")(fetcher) — both are populated whilestate !== "idle". Stop.
- Pass → Read
Additional Documentation
\x3CForm>component: See references/form.md for\x3CForm>vs native\x3Cform>vsfetch(), progressive enhancement, redirect-after-success, and validation error display viauseActionData.useFetcher: See references/fetcher.md for inline mutations, list operations, popovers,fetcher.state,fetcher.data,fetcher.Form,fetcher.submit,fetcher.load.- Optimistic UI: See
references/optimistic-ui.md for
fetcher.formDataanduseNavigation.formData, when to apply, and reverting on failure. - File uploads: See references/uploads.md
for
unstable_parseMultipartFormData,unstable_createMemoryUploadHandler,unstable_createFileUploadHandler, and bounded handlers. - Intent-based actions: See
references/intent-actions.md for
multiple actions on one route via the FormData
intentfield.
Comparison
| Concern | \x3CForm> |
useFetcher |
Native \x3Cform> |
fetch() |
|---|---|---|---|---|
| URL change / history entry | Yes | No | Yes (hard nav) | No |
| Works without JS | Yes | Yes | Yes | No |
| Revalidates loaders | Yes | Yes | Yes (hard reload) | No |
| Pending state hook | useNavigation() |
fetcher.state |
None | Manual |
| Optimistic input source | navigation.formData |
fetcher.formData |
None | Manual |
| In-app mutation use case | Create / delete / multi-step | Inline / row / toggle | External targets only | Never for own routes |
- 确保已安装 OpenClaw(本地或 Docker 部署)
- 在对话框中输入安装命令:
/install remix-v2-forms - 安装完成后,直接呼叫该 Skill 的名称或使用
/remix-v2-forms触发 - 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
Remix V2 Forms 是什么?
Remix v2 form submissions and mutations. Use when implementing forms, optimistic UI, file uploads, or multi-action routes. Triggers on <Form>, useFetcher, us... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 51 次。
如何安装 Remix V2 Forms?
在 OpenClaw 或 Claude Code 对话框中运行命令「/install remix-v2-forms」即可一键安装,无需额外配置。
Remix V2 Forms 是免费的吗?
是的,Remix V2 Forms 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。
Remix V2 Forms 支持哪些平台?
Remix V2 Forms 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。
谁开发了 Remix V2 Forms?
由 Kevin Anderson(@anderskev)开发并维护,当前版本 v1.0.0。