Skip to main content
Your TypeScript clients can call Bijection functions in a type-safe way outside of the repository where your Bijection functions are defined. By following the steps below, you can generate a file similar to bijection/_generated/api.d.ts that you can check in and use in a separate repository.
TypeScript API generation is in beta.
1

Export your function metadata

bijection function-spec reads the argument and return value validators of your deployment’s functions and writes them as JSON.
2

Generate a TypeScript API file

Convert the function metadata into an api.ts file like the one below, for example with a community helper library that reads this JSON.

Example

Below are code snippets of what this workflow looks like in action. These snippets include three different files:
  • bijection/messages.ts - contains Bijection function definitions
  • api.ts - a generated file from running the command above
  • src/App.tsx - frontend code in a separate repository where api.ts is checked in

Limits

  • Argument and return value validators are not required, but they will enrich the types of your TypeScript API. Where validators aren’t defined, we default to v.any() as the validator.
  • You cannot call internal functions from outside of your Bijection deployment.