metaxy
End-to-end typesafe RPC between Rust lambdas on Vercel and any TypeScript frontend.
This is the main entry point for the project — a facade crate that re-exports
the metaxy-macro proc macros
together with all runtime dependencies they need.
Installation
[]
= "0.1"
= { = "1", = ["derive"] }
That's it — no need to add vercel_runtime, serde_json, tokio, url, or
http-body-util manually.
Usage
Query (GET)
use rpc_query;
async
The macro generates a full Vercel handler that:
- Reads
namefrom the?input=<JSON>query parameter - Returns
{ "result": { "type": "response", "data": "Hello, World!" } } - Responds to
OPTIONSwith CORS preflight headers - Rejects non-GET methods with
405
Query without input
use rpc_query;
async
Mutation (POST)
use rpc_mutation;
use Deserialize;
async
Mutations read input from the JSON request body and only accept POST.
Returning Result
use rpc_query;
async
Ok(value)→ HTTP 200 success responseErr(error)→ HTTP 400 error response
Response format
Success (HTTP 200):
Error (HTTP 400):
Constraints
- Functions must be
async. - Each function accepts at most one parameter.
- Input types must implement
serde::Deserialize. - Output types (and
Oktypes inResult) must implementserde::Serialize.
Re-exports
For convenience, the crate re-exports serde::{Serialize, Deserialize}, so you
can write use metaxy::Serialize; if you prefer.
Related crates
metaxy-macro— the proc macros themselves (re-exported by this crate).metaxy-cli— CLI that scans your#[rpc_query]/#[rpc_mutation]functions and generates TypeScript types and a typed client.
License
MIT OR Apache-2.0