Quickstart
Get started with cilantro-sdk and cilantro-react in minutes
Quickstart
Get up and running in just a few minutes. Choose the React path for Next.js/React apps, or the SDK only path for Node/backend or custom UI.
Installation
Install both packages:
npm install cilantro-react cilantro-sdk
Or with yarn:
yarn add cilantro-react cilantro-sdk
Or with pnpm:
pnpm add cilantro-react cilantro-sdk
In browser apps, import polyfills once at the top of your entry (e.g. root layout):
import 'cilantro-sdk/polyfills';
Two paths
React (Next.js)
- Wrap your app with CilantroProvider (see cilantro-react Setup).
- Use useAuth for login/register/logout and useWallet for the wallet list.
That's it — auth and wallet context are handled for you. No manual setAuth for user JWT.
SDK only (Node/backend or custom UI)
Configure the SDK once with configure, then use loginAndSetAuth (or login + setAuth) for user auth. Wallet responses expose a data field; use { data } or extractResponseData (from cilantro-react) to unwrap.
1. Configure and authenticate
import { configure, setAuth, clearAuth } from 'cilantro-sdk';
import { loginAndSetAuth, login } from 'cilantro-sdk/auth';
// Configure once at startup
configure({ apiKey: process.env.PLATFORM_API_KEY, baseURL: 'https://api.cilantro.gg' });
// Option A: Login and set JWT in one step (recommended)
await loginAndSetAuth({ usernameOrEmail: 'user@example.com', password: 'SecurePass123!' });
// Option B: Login then set token yourself
const result = await login({ usernameOrEmail: 'user@example.com', password: 'password123' });
setAuth({ jwt: result.data.accessToken });
// Clear auth (e.g. logout)
clearAuth();
2. Your first wallet
import { create, findAll, findOne } from 'cilantro-sdk/wallet';
const { data } = await create({ name: 'My Wallet', userId: 'user-id' });
const walletId = data.id;
const wallet = await findOne(walletId);
const wallets = await findAll();
3. Send your first transaction
Custodial (server holds keys): use sendSOL / sendSPL from cilantro-sdk/wallet. Non-custodial: use sendSOLWithSigner / sendSPLWithSigner from cilantro-sdk/helpers, or prepareTransaction → sign with signTransactionWithEmailSigner → submitTransaction. See Wallet Module and Helpers.