🧙♂️Server actions
With @atomico/vite, you will be able to use server-side functions in an environment-agnostic way, suitable for certain serverless and edge environments.
Example with Cloudflare.
import type { Props } from "atomico";
import { getUserById } from "./api";
function app({id}: Props<typeof app>){
const user = useAsync(()=>getUserById({id}),[id]);
return <host>
{user.name} - {user.phone}
</host>
}
app.props = { id: Number }export async function getUserById({ id }:{ id: number}){
const result = await fetch(
`https://jsonplaceholder.typicode.com/users/${id}`
);
return result.json();
}Last updated
Was this helpful?
