ClientActionFunctionArgs
Client action arguments with access to the server 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
interface ClientActionFunctionArgs extends LoaderFunctionArgs {
serverAction: <T = unknown>() => Promise<T>;
}Contract
Extends LoaderFunctionArgs with serverAction<T>(): Promise<T>. The installed application transport forwards the request to the registered server action when this callback is invoked.
import type { ClientActionFunctionArgs } from "@kasperrt/smolter/preact";
interface SavedTask {
id: string;
}
export async function clientAction({ serverAction }: ClientActionFunctionArgs) {
const task = await serverAction<SavedTask>();
return { ...task, saved: true };
}Usage and limits
Keep mutations in actions rather than components. Calling serverAction is optional; a client-only action may perform client-side work instead. The callback requires transport wiring and the generic is a type assertion, not runtime response validation.
Fields
serverAction
serverAction: <T = unknown>() => Promise<T>;