useActionData
Read the result of a navigating page action.
Compatibility
ReactAvailable in this renderer's browser integration.
React SSRAvailable to this renderer's SSR integration; browser event handlers run after hydration.
PreactAvailable in this renderer's browser integration.
Preact SSRAvailable to this renderer's SSR integration; browser event handlers run after hydration.
Import from @kasperrt/smolter/react @kasperrt/smolter/preact
Signature
function useActionData<T = RouteModule>(
route?: T & LoaderSource,
): ActionData<T> | undefined;Parameters
Optionally pass a typed route object or an action function type generic.
Returns
Inferred action result or undefined.
Usage
Import this API from one of the entry points listed above. Keep server and build helpers in their dedicated subpaths.
const result = useActionData<typeof action>();
return <p>{result?.message}</p>;Behavior and edge cases
Fetcher action results belong to fetcher.data and are not returned here. Navigating to another route clears page action data. The hook does not submit anything; use Form or router.submit.