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.
RPC (Remote Procedure Calls)
Define server-side functions using defineMethod and call them from the client using useCall or useFetch.
Server
src/server/tasks.ts
1import { defineMethod } from "heliumts/server";23// Getting tasks4export const getTasks = defineMethod(async (args: { status: string }) => {5 // Add your own database logic here6 return [{ id: 1, name: "Task 1", status: args.status }];7});89// Creating a new task10export const createTask = defineMethod(async (args: { name: string }) => {11 // Add your own create task logic12 return { id: 2, name: args.name };13});
Client
src/pages/tasks.tsx
1import { useFetch, useCall } from "heliumts/client";2import { getTasks, createTask } from "heliumts/server";34export default function TasksPage() {5 // Fetch data (auto-runs on mount)6 // Data is typed based on server method return type7 const { data, isLoading } = useFetch(getTasks, { status: "open" });89 // Mutation (callable function)10 // The call function is typed based on server method args and return type11 const { call: add, isCalling } = useCall(createTask, {12 invalidate: [getTasks] // Auto-refresh getTasks after success everywhere it's used13 });1415 return (16 <div>17 <button onClick={() => add({ name: "New Task" })}>18 {isCalling ? "Adding..." : "Add Task"}19 </button>20 {data?.map(task => <div key={task.id}>{task.name}</div>)}21 </div>22 );23}