clientActionIn addition to (or in place of) your action, you may define a clientAction function that will execute on the client.
Each route can define a clientAction function that handles mutations:
export const clientAction = async ({
request,
params,
serverAction,
}: ClientActionFunctionArgs) => {
invalidateClientSideCache();
const data = await serverAction();
return data;
};
This function is only ever run on the client and can be used in a few ways:
action for full-client routesclientLoader cache by invalidating the cache on mutationsparamsThis function receives the same params argument as an action.
requestThis function receives the same request argument as an action.
serverActionserverAction is an asynchronous function that makes the fetch call to the server action for this route.
See also: