Generating program plugins

Generate typed plugins for your Solana programs using Codama

Program plugins are generated from program IDLs by Codama. Codama's CLI is the quickest path to a working plugin: two commands set up a configuration file in your repo and emit a Kit-compatible package containing both standalone helpers and a typed program plugin.

This page focuses on how the generated output fits into the Kit ecosystem. Codama itself has comprehensive docs that go much deeper into IDLs, visitors, and renderer configuration.

What Codama generates

For every program, the JavaScript renderer emits two things side by side: standalone helpers for use without a client, and a program plugin that installs a typed namespace on a Kit client.

// Standalone helpers, one per instruction and account defined in the IDL.
import { decodeMyAccount, fetchMyAccount, getMyInstruction } from '@your-scope/your-program';
 
// Program plugin — installs `client.yourProgram.accounts` and `client.yourProgram.instructions`.
import { yourProgram } from '@your-scope/your-program';

Both forms are generated automatically from your IDL. The standalone helpers tree-shake well and keeps JS bundles small, while the program plugin is the most ergonomic way to use the program from a Kit client.

Set up Codama with codama init

Install Codama as a dev dependency and run codama init. The CLI prompts you for the path to your IDL and writes a codama.json configuration file at the root of your project. Make sure to select the JS client option to generate a Kit-compatible program library.

pnpm install codama
codama init

The CLI auto-detects Anchor IDLs and configures the conversion step for you, so this same flow works for both native programs (with a Codama IDL) and Anchor programs (with an Anchor IDL).

Generate the plugin with codama run js

Once the configuration file exists, generating the JavaScript client is a single command. Codama installs the renderer the first time it runs and writes the generated files to the path declared in the configuration.

codama run js

The output includes the standalone helpers, the program plugin, and the supporting types. Importing it from a Kit client looks the same as any other program plugin:

import {  } from '@solana/kit';
import {  } from '@solana/kit-plugin-rpc';
import {  } from '@solana/kit-plugin-signer';
import {  } from '@your-scope/your-program';
 
const  = await ()
    .(())
    .(())
    .(());

Configure the renderer

The codama.json file generated by codama init controls where the output lands and which visitors run before the renderer. You can edit it to rename accounts, add custom transformations, or change the output directory. See the Codama JS renderer docs for the full list of configuration options.

If you need more than one client (for example, both JavaScript and Rust), additional renderers can be added to the same configuration file and run with codama run --all.

Publish your generated plugin

Once your plugin is generating cleanly, publishing it follows the same pattern as the official @solana-program/* packages. A few conventions worth keeping in mind:

  • Use a @<scope>/<program-name> package layout, with a single entry point that re-exports both the standalone helpers and the programName() plugin.
  • Once published, open a PR against anza-xyz/kit to list your plugin on the Available plugins page so other developers can find it.

Next steps

On this page