Actions
Handles data mutations and side effects on the server
- Just like loader, this is a function which runs only on server
- actions can be create by exporting a function called action in the route files
import type { ActionFunction } from "@remix-run/react";
import { json } from "@remix-run/node";
export const action: ActionFunction = async ({ request }) => {
const formData = await request.formData();
// Do something with the form data
await someAsyncMutation(formData);
return json({ message: "Successful!" });
};