Skip to content
Resources

The example app

A small Next.js app on mainnet that registers, deposits, pays privately and withdraws, and how to run it.

apps/nimbus-example is a small Next.js App Router app built on the SDK. It runs on mainnet with real funds. It covers what every app needs: connect, register, deposit, Private Send, withdraw, balances, history and recovery.

Each file is short and maps onto a page of these docs. Read them side by side.

Run it

The app lives in the Nimbus monorepo and uses the SDK from source. Build the SDK's WebAssembly and files first, then start the app.

Build the SDK and its files

From the repository root, install, then build the three WebAssembly modules the SDK ships:

pnpm install
just build-nimbus-primitives-wasm
just build-umbra-prover-wasm
just build-witness-graph-wasm

Then build the SDK, and gather its files into its assets/ folder:

pnpm --filter "@umbra/nimbus-example^..." run build
pnpm --filter @umbra/nimbus-solana-web run build:assets

Set the environment

Copy .env.example to .env.local in apps/nimbus-example. Both settings are optional:

VariableWhat it does
NEXT_PUBLIC_NIMBUS_RPCA Solana RPC to use in place of the preset's public one.
NEXT_PUBLIC_NIMBUS_GATEWAY_TOKENThe gateway token every session sends. Without it, accounts open and read, and every payment fails unauthorized.

Next.js writes both into the page, so every visitor can read the token. To get a token, email dev@umbraprivacy.com or reach out to any Umbra team member.

Copy the files and start

cd apps/nimbus-example
pnpm assets
pnpm dev

pnpm assets runs nimbus-solana-web copy-assets public/nimbus. next.config.mjs sends the two cross-origin isolation headers with every route.

Its other scripts are pnpm build and pnpm start for a production build, and pnpm typecheck. pnpm tokens rewrites the token list, as the table below explains.

Where each feature lives

FeatureFilesDocs
Loading the SDK once, in the browsercomponents/app-provider.tsx, lib/nimbus/load.tsUse it with React
Listing wallets and connecting onecomponents/connect-card.tsxWallets
Opening a session, and where its sign-in is keptlib/nimbus/session.ts, components/connect-card.tsxSessions
Registering before the first depositcomponents/account-gate.tsx, components/register-card.tsx, lib/nimbus/register.tsRegistration
Deposit, withdraw and Private Send on one cardcomponents/action-card.tsx, components/flow-form.tsxDeposit, Withdraw, Transfer
Each payment, in one small functionlib/nimbus/deposit.ts, lib/nimbus/withdraw.ts, lib/nimbus/private-send.tsThe function template
One description of a withdrawal or Private Send resultlib/nimbus/spend.tsResults and errors
A message for each progress stagelib/progress.ts, components/keep-tab-open.tsxShow progress
Syncing, and balances grouped per tokencomponents/use-account.ts, lib/nimbus/account.tsBalances, Sync
Reserved funds with a Release buttoncomponents/balances-panel.tsx, lib/nimbus/account.tsReserved funds
History, ten entries a pagecomponents/activity-list.tsx, lib/nimbus/history.ts, lib/activity.tsHistory
A pending deposit, and a refund of a stuck onecomponents/recovery-card.tsx, lib/nimbus/recovery.tsIf the deposit is still pending
Token names and logoslib/tokens.ts, scripts/fetch-tokens.tsTokens

The token logos are saved under public/tokens/, because a cross-origin isolated page shows images from another site only when that site allows it. pnpm tokens fetches them again when the preset's tokens change.

What it leaves out

The example keeps to the basics. It runs only on mainnet, and asks each service directly rather than through the coordinator. It does not sync in the background. Use it with React shows how to add that.

Next

Last updated

On this page