create-codama-clients
v1.0.0
Published
Auto-discover and batch-generate Codama TypeScript clients from Solana program IDLs
Maintainers
Readme
create-codama-clients
Zero config, ero installation tool that makes TypeScript clients from your Solana program IDLs.
Just run npx create-codama-clients. This package will download, find all IDL files in your project, and generate TypeScript clients for all your programs with one command.
The problem this solves
The Codama CLI (codama run) requires:
- A
codama.jsonconfig file for each program - Manual configuration of IDL paths and output directories
- Separate commands or shell scripts to handle multiple programs
With create-codama-clients, you can generate clients for all your programs in one command, with zero configuration.
Usage
Basic usage (recommended)
npx create-codama-clientsThis will:
- Look for IDL files in
target/idl/(Anchor's default location) - Generate a TypeScript client for each IDL found
- Output clients to
dist/<idl-name>-client/folders (e.g.,dist/election-client/)
Custom directories
npx create-codama-clients --idl-dir ./idls --output-dir ./clientsOptions
-i, --idl-dir <dir> Directory containing IDL files (default: target/idl)
-o, --output-dir <dir> Directory for generated clients (default: dist)
-h, --help Show this help messageExample output
🔍 Searching for IDL files in target/idl...
📦 Found 2 IDL file(s)
✅ Generated client for election at dist/election-client
✅ Generated client for voting at dist/voting-client
🎉 Successfully generated 2 client(s)Each generated client folder (e.g., dist/election-client/) contains:
- TypeScript types for your program's accounts and instructions
- Helper functions for interacting with your program
- Full compatibility with
@solana/kit
Requirements
Your project should have IDL files (JSON format) from:
- Anchor programs (
anchor buildgenerates these intarget/idl/) - Shank-based programs
- Any other Codama-compatible IDL format
How it works
For each IDL file found:
- Loads the IDL JSON
- Converts it to a Codama root node using
@codama/nodes-from-anchor - Generates TypeScript client code using
@codama/renderers-js - Outputs to
<output-dir>/<idl-filename>-client/(the-clientsuffix is automatically appended)
Comparison with Codama CLI
| Feature | create-codama-clients | codama run |
| ----------------- | ----------------------- | ------------------------- |
| Installation | None (npx) | Requires local install |
| Configuration | Zero config | Requires codama.json |
| Multiple programs | Automatic | Manual config per program |
| Discovery | Auto-finds IDLs | Manual paths |
License
ISC
