Note:
HeliumTS is under pre-beta and active development. Expect bugs and breaking changes. If you find any issues, please report them in our GitHub
A stable release is planned for early December 2025.
Data Mutation
HeliumTS provides the useCall hook for performing mutations (create, update, delete operations). Unlike useFetch, it doesn't automatically execute — you call it manually when needed.
useCall
The useCall hook is designed for writing/modifying data. It provides a function to trigger the server method and tracks the execution state.
Basic Usage
1import { useCall } from "heliumts/client";2import { createTask } from "heliumts/server";34function CreateTaskForm() {5 const { call, isCalling, error } = useCall(createTask);67 const handleSubmit = async (name: string) => {8 const result = await call({ name });9 if (result) {10 console.log("Task created:", result);11 }12 };1314 return (15 <form16 onSubmit={(e) => {17 e.preventDefault();18 handleSubmit(e.target.taskName.value);19 }}20 >21 <input name="taskName" placeholder="Task name" />22 <button type="submit" disabled={isCalling}>23 {isCalling ? "Creating..." : "Create Task"}24 </button>25 {error && <p className="error">{error}</p>}26 </form>27 );28}
Return Values
| Property | Type | Description |
|---|---|---|
call | (args: TArgs) => Promise<TResult | undefined> | Function to execute the server method |
isCalling | boolean | Whether a call is in progress |
error | string | null | Error message if the call failed |
stats | RpcStats | null | RPC statistics (timing, etc.) |
Options
1const { call } = useCall(method, {2 invalidate: [getTasks, getTaskCount],3 onSuccess: (result) => console.log("Success:", result),4 onError: (error) => console.error("Error:", error),5});
| Option | Type | Description |
|---|---|---|
invalidate | MethodStub[] | Array of methods whose cached data should be invalidated after a successful call. This triggers automatic refetch for all useFetch hooks using those methods. |
onSuccess | (result: TResult) => void | Callback fired after a successful call |
onError | (error: string) => void | Callback fired when the call fails |