Coda

Installation

Install and configure Coda for your project

Coda can be installed and used in several ways depending on your project needs.

Quick Start (No Installation)

Run Coda directly without installing:

bunx @macalinao/coda generate

This will:

  • Search for your IDL in ./target/idl/
  • Generate TypeScript client in ./src/generated/
  • Exit after completion

This approach is ideal for trying Coda or one-time generation.

Global Installation

For frequent use across multiple projects:

bun add -g @macalinao/coda

Then use the command directly:

coda generate

Project Installation

Add Coda as a development dependency:

bun add -D @macalinao/coda

Add scripts to your package.json:

{
  "scripts": {
    "codegen": "coda generate",
    "build": "anchor build && coda generate"
  }
}

This ensures consistent client generation across your team.

CLI Commands

generate (alias: gen)

Generate TypeScript client from an Anchor IDL:

coda generate                    # Use default locations
coda gen                        # Short alias

# With custom options:
coda generate \
  --idl ./my-idl.json \        # Specify IDL path
  --output ./my-client          # Specify output directory

init

Create a configuration file:

coda init                       # Creates coda.config.mjs

Alternative Package Managers

npm

npx @macalinao/coda generate          # Direct execution
npm install -g @macalinao/coda        # Global installation

pnpm

pnpm dlx @macalinao/coda generate     # Direct execution
pnpm add -g @macalinao/coda           # Global installation

yarn

yarn dlx @macalinao/coda generate     # Direct execution
yarn global add @macalinao/coda       # Global installation

Requirements

  • Node.js 18+: Required for running Coda
  • Anchor IDL: Generated by anchor build
  • ES Modules: Add "type": "module" to your package.json

Verify Installation

coda --version    # Display version
coda --help       # Show available commands

Next Steps

  • Basic usage: Run coda generate with default settings
  • Custom configuration: Use coda init to create a config file
  • Learn more: See the Quick Start guide