next-form-action
Version:
A TypeScript library for handling server actions in Next.js with type-safe error handling and callbacks
15 lines • 848 B
TypeScript
import { ActionErrorState, ActionParams, ActionState, ActionSuccessState } from "@/types";
export declare class ActionResponse extends Error {
readonly state: ActionErrorState | ActionSuccessState;
constructor(state: ActionErrorState | ActionSuccessState);
}
export declare class ActionError extends ActionResponse {
constructor(state: ActionErrorState);
}
export declare class ActionSuccess extends ActionResponse {
constructor(state: ActionSuccessState);
}
export declare function error(message: ActionState["message"], params?: ActionParams): never;
export declare function success(message: ActionState["message"], params?: ActionParams): never;
export declare function createAction<T = unknown>(handler: (data: T) => Promise<ActionState>, context?: string): (data: T) => Promise<ActionState>;
//# sourceMappingURL=index.d.ts.map