convex-typegen
Rust types from your Convex schema.ts and function modules. Runs in build.rs so generated code stays in sync with your backend.
Docs: docs.rs/convex-typegen
Setup
- Add the crate (library + build script):
- Add
build.rs:
use *;
cargo buildwrites the generated file (see defaults below). Include it in your crate (mod convex_types;or whatever matchesout_file) and pull inconvex_typegen::prelude::*where you call Convex with the generated arg types.
A full minimal setup lives in examples/basic in this repo.
Generated names
Function argument structs are named {Module}{Export}Args when the export does not already start with the module file name (without .ts). Examples:
| Module file | Export | Generated struct |
|---|---|---|
games.ts |
getGame |
GamesGetGameArgs |
mod_a.ts |
list |
ModAListArgs |
tasks.ts |
tasksSearch |
TasksSearchArgs |
FUNCTION_PATH strings are unchanged (e.g. "games:getGame").
Defaults
| Field | Default |
|---|---|
schema_path |
convex/schema.ts |
out_file |
src/convex_types.rs |
convex_dir |
convex |
Paths are relative to the package directory when Cargo runs the build script.
Function sources: every *.ts under convex_dir, except the schema file, _generated/, node_modules/, and *.d.ts. Set function_paths to a non-empty list to skip discovery and pass files explicitly.
Features
| Feature | Default | Description |
|---|---|---|
client |
on | Re-exports ConvexClientExt, IntoConvexValue, ConvexValueExt (pulls in the convex crate). |
verbose |
off | Print Oxc diagnostics to stderr during parse failures. |
Build-only usage (smaller dependency tree):
[]
= { = "0.3", = false }
Serde
Generated code pulls serde and serde_json through convex-typegen, so a minimal app crate does not need those as direct dependencies unless you use them yourself.
License
MIT — see LICENSE.