Form Action

Form Action

Actions handle form submissions and data mutations. Like loaders, they run on both server and client by default. Use a separate .ts file for server-only actions that need database access or secrets.

Submit Form

Action Result

Submit the form to see the action result

Example Code

import type { RouteActionArgs } from "@udibo/juniper";

export async function action({ request }: RouteActionArgs) {
  const formData = await request.formData();
  const name = formData.get("name");
  // Process form data...
  return { success: true, message: "Submitted!" };
}

// In component:
<Form method="post">
  <input name="name" />
  <button type="submit">Submit</button>
</Form>