What are Remix actions?

Answer

Actions in Remix handle form submissions and mutations on the server. Export an action function from a route: export async function action({ request }) { const formData = await request.formData(); const name = formData.get("name"); await db.createUser({ name }); return redirect("/users"); }. In the component, use a regular HTML <Form> (Remix's enhanced version): <Form method="post"><input name="name" /><button>Submit</button></Form>. Actions are called when the form is submitted via POST. Key behaviors: Progressive enhancement: works without JavaScript (browser native form POST). JavaScript-enhanced: with JS, Remix intercepts the form submission, calls the action via fetch, and re-runs loaders for fresh data — no page reload. Optimistic UI: use useNavigation and useFetcher for optimistic updates. Validation: return validation errors from action: return json({ errors }, { status: 400 }).