UNPKG

next-safe-action

Version:

Type safe and validated Server Actions in your Next.js project.

52 lines (49 loc) 1.89 kB
import { H as HookSafeActionFn, a as HookCallbacks, U as UseActionHookReturn, b as UseOptimisticActionHookReturn, } from "./hooks.types-RxW9RXw1.mjs"; export { d as HookActionStatus, c as HookSafeStateActionFn, e as HookShorthandStatus, I as InferUseActionHookReturn, g as InferUseOptimisticActionHookReturn, h as InferUseStateActionHookReturn, f as UseStateActionHookReturn, } from "./hooks.types-RxW9RXw1.mjs"; import { S as StandardSchemaV1, I as InferInputOrDefault } from "./index.types-CJ06jFQp.mjs"; /** * Use the action from a Client Component via hook. * @param safeActionFn The action function * @param cb Optional base utils and callbacks * * {@link https://next-safe-action.dev/docs/execute-actions/hooks/useaction See docs for more information} */ declare const useAction: <ServerError, S extends StandardSchemaV1 | undefined, CVE, Data>( safeActionFn: HookSafeActionFn<ServerError, S, CVE, Data>, cb?: HookCallbacks<ServerError, S, CVE, Data> ) => UseActionHookReturn<ServerError, S, CVE, Data>; /** * Use the action from a Client Component via hook, with optimistic data update. * @param safeActionFn The action function * @param utils Required `currentData` and `updateFn` and optional callbacks * * {@link https://next-safe-action.dev/docs/execute-actions/hooks/useoptimisticaction See docs for more information} */ declare const useOptimisticAction: <ServerError, S extends StandardSchemaV1 | undefined, CVE, Data, State>( safeActionFn: HookSafeActionFn<ServerError, S, CVE, Data>, utils: { currentState: State; updateFn: (state: State, input: InferInputOrDefault<S, void>) => State; } & HookCallbacks<ServerError, S, CVE, Data> ) => UseOptimisticActionHookReturn<ServerError, S, CVE, Data, State>; export { HookCallbacks, HookSafeActionFn, UseActionHookReturn, UseOptimisticActionHookReturn, useAction, useOptimisticAction, };