You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Use the stateful action from a Client Component via hook. Used for actions defined with [`stateAction`](https://next-safe-action.dev/docs/safe-action-client/instance-methods#action--stateaction).
We'll use these exported functions in the following examples.
81
+
82
+
## `/`
83
+
84
+
The library exports several utility types from the root path that help you infer types of a safe action client, a middleware function or a safe action function.
85
+
86
+
Here's the list of utility types exported from `next-safe-action` path:
87
+
-`InferSafeActionFnInput`: infer input types of a safe action function
88
+
-`InferSafeActionFnResult`: infer result type of a safe action function
89
+
-`InferMiddlewareFnNextCtx`: infer the type of context returned by a middleware function using the `next` function
90
+
-`InferCtx`: infer the type of context of a safe action client, or the context passed to a middleware function
91
+
-`InferMetadata`: infer the type of metadata of a safe action client or middleware function
92
+
-`InferServerError`: infer the type of the `serverError` of a safe action function, middleware function or safe action function
The library also exports three types from the `/hooks` path that help you infer types when using `useAction`, `useOptimisticAction` and `useStateAction` hooks.
185
+
186
+
Here's a list of utility types exported from `next-safe-action/hooks`:
187
+
188
+
-`InferUseActionHookReturn`: infers the return type of the `useAction` hook - only works with actions defined using the [`action`](/docs/safe-action-client/instance-methods#action--stateaction) method
189
+
-`InferUseOptimisticActionHookReturn`: infers the return type of the `useOptimisticAction` hook - only works with stateless actions defined using the [`action`](/docs/safe-action-client/instance-methods#action--stateaction) method
190
+
-`InferUseStateActionHookReturn`: infers the return type of the `useStateAction` hook - only works with stateful actions defined using the [`stateAction`](/docs/safe-action-client/instance-methods#action--stateaction) method
0 commit comments