Skip to content

The example app

A complete Next.js wallet on mainnet, in its own public repository, that registers, deposits, pays privately and withdraws, and how to run it.

The Nimbus integration examples repository holds complete apps built on the SDK. Each one installs the SDK from npm. You can copy one folder out of the repository and run it on its own.

Its first example is nextjs-wallet, a private wallet built with Next.js. 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

Get what it needs

  • Node.js 20.9 or later.
  • A Solana wallet extension that supports the Wallet Standard. It needs a little SOL for network fees, and the token you want to deposit.
  • A mainnet gateway token. To get one, email dev@umbraprivacy.com or reach out to any Umbra team member.
  • A Solana RPC endpoint from a provider. The public api.mainnet-beta.solana.com refuses most requests from browsers.

Clone it and set the environment

git clone https://github.com/umbra-defi/nimbus-integration-examples.git
cd nimbus-integration-examples/examples/nextjs-wallet
cp .env.example .env.local

Fill in the two settings in .env.local:

VariableWhat it does
NEXT_PUBLIC_NIMBUS_RPCYour RPC endpoint, used 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. Restart the app after you change them.

Install and start

npm install
npm run dev

npm install also runs nimbus-solana-web copy-assets public/nimbus, which copies the SDK's files. next.config.mjs sends the two cross-origin isolation headers with every route. The app is then at http://localhost:3000.

npm run build and npm start give a production build. npm run typecheck checks the types. npm run tokens rewrites the token list, as the table below explains.

Where each feature lives

Every path is under examples/nextjs-wallet.

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.tsSDK, sessions and contexts
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/token-list.json, lib/tokens.ts, scripts/fetch-tokens.tsTokens

The token logos are saved in the app, because a cross-origin isolated page shows images from another site only when that site allows it. npm run tokens fetches the names and logos again. Pass a mint address to add a token: npm run tokens -- <mint>.

What it leaves out

The example keeps to the basics. It runs only on mainnet, and it does not sync in the background. Use it with React shows how to add that.

Next

Last updated

On this page