Getting Started
metaxy is an end-to-end typesafe RPC toolkit for building serverless APIs with Rust on Vercel. Write plain Rust functions, and get a fully typed TypeScript client — no manual sync required.
Installation
Install the CLI
cargo install metaxy-cliAdd the macro crate to your Rust project
cargo add metaxyQuick Start
Write a Rust lambda
// api/hello.rs
use metaxy::rpc_query;
#[rpc_query]
async fn hello(name: String) -> String {
format!("Hello, {}!", name)
}Generate TypeScript types and client
metaxy generate --dir api --output src/lib/rpc-types.ts --client-output src/lib/rpc-client.tsCall your lambda
- Any TypeScript frontend
import { createRpcClient } from './rpc-client';
const rpc = createRpcClient({ baseUrl: '/api' });
const greeting = await rpc.query('hello', 'World');
// greeting: string — "Hello, World from Rust on Vercel!"- Or 1 of 4 frameworks
import { createQuery } from './rpc.svelte';
let name = $state('World');
const hello = createQuery(rpc, 'hello', () => name);
// hello.data reactively updates when 'name' changesTry it live
createQuery(rpc, "hello", () => name) — auto-refetches as you type.
How it works
- Annotate Rust functions with
#[rpc_query]or#[rpc_mutation] - The CLI scans your
api/directory and parses Rust types viasyn - TypeScript types and a typed client are generated automatically
- Each Rust file deploys as a serverless lambda on Vercel