hunk.code_window: [web-fetch-api]: https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API
   [fastly-remix-server-adapter]: https://github.com/fastly/remix-compute-js/tree/main/packages/remix-server-adapter
   [fastly-compute-at-edge]: https://developer.fastly.com/learning/compute/
   [remix-google-cloud-functions]: https://github.com/penx/remix-google-cloud-functions
   [google-cloud-functions]: https://cloud.google.com/functions
   [firebase-functions]: https://firebase.google.com/docs/functions
   [remix-fastify]: https://github.com/mcansh/remix-fastify
   [fastify]: https://www.fastify.io
  
hunk.labels: keep keep keep replace keep keep keep keep keep
hunk.after_edit: [fastly-compute]: https://developer.fastly.com/learning/compute/
  
hunk.file_path: docs/other-api/adapter.md
hunk.type: replace
file: ---
  title: useActionData
  toc: false
  ---
  
  # `useActionData`
  
  Returns the serialized data from the most recent route action or `undefined` if there isn't one.
  
  ```tsx lines=[10,14]
  import type { ActionFunctionArgs } from "@remix-run/node"; // or cloudflare/deno
  import { json } from "@remix-run/node"; // or cloudflare/deno
  import { Form, useActionData } from "@remix-run/react";
  
  export async function action({
    request,
  }: ActionFunctionArgs) {
    const body = await request.formData();
    const name = body.get("visitorsName");
    return json({ message: `Hello, ${name}` });
  }
  
  export default function Invoices() {
    const data = useActionData<typeof action>();
    return (
      <Form method="post">
        <input type="text" name="visitorsName" />
        {data ? data.message : "Waiting..."}
      </Form>
    );
  }
  ```
  
  ## Additional Resources
  
  **Guides**
  
  - [Form Validation][form_validation]
  
  **Related API**
  
  - [`action`][action]
  - [`useNavigation`][use_navigation]
  
  **Discussions**
  
  - [Fullstack Data Flow][fullstack_data_flow]
  
  [form_validation]: ../guides/form-validation
  [action]: ../route/action
  [use_navigation]: ../hooks/use-navigation
  [fullstack_data_flow]: ../discussion/data-flow
  