Introducing a new way to review your PRs.

Read the announcement

solana-foundation / solana-web3.js

Solana JavaScript SDK

View on GitHub

23 documents · Updated Nov 16, 2026

docs / wallet-adapter

Wallet adapter integration

The wallet adapter package gives React applications one way to discover wallets, connect an account, inspect wallet capabilities, sign data, and submit transactions. It joins Wallet Standard wallets with Solana RPC connections and exposes the result as shared application state, while also offering a framework-neutral controller for non-React consumers.

Package role

Integration boundary

packages/…/index.ts is the main public entry point for the React providers, hooks, UI controls, controller types, and shared errors. The package uses Wallet Standard registration in the browser, so applications do not create one adapter object for each wallet. A wallet becomes available when it registers and advertises its Solana accounts and features.

The @solana/wallet-adapter/core entry point provides the controller and types without React. This split lets an application keep wallet behavior in a shared client while choosing React hooks or another view layer for presentation. The package also exposes separate ui and stylesheet entry points for applications that use its built-in controls. Its peer contract covers @solana/kit and @solana/web3.js, while React and React DOM remain optional for consumers that use only the core surface.

References: packages/…/index.ts• L1-6 packages/…/core.ts• L1-9 packages/…/package.json• L24-39 packages/…/package.json• L63-67 packages/…/README.md• L3-7

Capability model

The package reports wallet capabilities instead of assuming that every wallet supports every action. The shared wallet state can expose transaction signing, message signing, Sign In With Solana, off-chain message signing, and supported transaction versions only when the connected account and wallet advertise those features.

This model lets the application choose a safe action before it asks the wallet to perform it. The state also exposes whether off-chain message signing is available, while the operation methods remain optional for capabilities that a wallet does not provide. It preserves a small compatibility surface for older wallet-adapter consumers, such as wallet identity views and WalletReadyState values.

References: packages/…/types.ts• L26-43 packages/…/types.ts• L50-74 packages/…/types.ts• L76-116 packages/…/wallet-controller.ts• L143-166

Application context

Provider hierarchy

The application places ConnectionProvider around WalletProvider. The outer provider supplies the Solana RPC connection. The wallet provider supplies the selected wallet, account state, capabilities, and wallet operations. WalletModalProvider is an optional UI layer that turns wallet selection into a shared modal flow.

The relationship between these contexts is shown below.

flowchart TD
    App[React application]
    Connection[ConnectionProvider\nRPC connection]
    Wallet[WalletProvider\nwallet state and operations]
    Modal[WalletModalProvider\nselection UI state]
    Features[Application features\naccount, signing, transactions]
    App --> Connection
    Connection --> Wallet
    Wallet --> Modal
    Modal --> Features
    Wallet --> Features
    Features --> Connection

useConnection() requires the connection provider. useWallet() requires the wallet provider. Missing either context is a configuration error, which makes an incorrect provider tree visible at the point of use.

For mount, reconnect, selection, storage, and disposal behavior, see Wallet provider and controller lifecycle.

References: packages/…/ConnectionProvider.tsx• L7-43 packages/…/WalletProvider.tsx• L19-29 packages/…/WalletModalProvider.tsx• L6-35 examples/…/providers.tsx• L29-67

Shared wallet state

useWallet() returns an immutable snapshot for the current wallet environment. The snapshot joins discovery and selection with connection status, the active account, its public key, its signer, supported transaction versions, and the operations that can act on that state.

The main state groups are:

  • Discovery: available wallets, the selected wallet, and the connected wallet.
  • Connection: connected, connecting, disconnecting, and the current status.
  • Account: public key, account address, signer, and supported transaction versions.
  • Operations: select, connect, disconnect, send, sign, and sign-in actions when supported.

The controller is the source of this snapshot. React subscribes to it so wallet registration, connection changes, and capability changes update application features without requiring each feature to manage its own wallet listener.

References: packages/…/types.ts• L76-116 packages/…/WalletProvider.tsx• L83-131 packages/…/wallet-controller.ts• L516-592

Wallet operations

Wallet selection and connection

Wallet selection is separate from connection. The application or a wallet picker selects a wallet by name, then connect() asks that wallet to authorize an account. The package can restore a prior account when auto-connect is enabled, and it keeps the selected wallet and connected account visible as distinct parts of the state.

Wallets are discovered from the browser registry and filtered by the configured chain or application predicate. Unknown selections and missing selections fail before a connection request reaches a wallet. A disconnect clears the active selection and releases the connection.

References: packages/…/wallet-controller.ts• L206-267 packages/…/types.ts• L101-115 packages/…/README.md• L48-58

Transaction signing and sending

The package accepts both legacy and versioned @solana/web3.js transactions. It checks the transaction version against the connected account's advertised support before signing. It can use a wallet's direct sign-and-send capability or obtain a signed transaction and submit it through the supplied RPC connection.

When the application sends a legacy transaction that lacks its fee payer or recent blockhash, the adapter completes those values from the connected account and the connection before the wallet signs. Additional local signers are applied first. The send path keeps the transaction's client-side lifetime data when signing returns a new transaction object and checks that caller-provided signatures remain intact.

This flow separates wallet authorization from network submission while keeping both choices behind one operation. The connection endpoint is also checked against a known Solana cluster name when the wallet chain identifies one, which helps prevent a wallet for one network from submitting through a public endpoint for another.

References: packages/…/wallet-controller.ts• L400-515 packages/…/transactions.ts• L15-31 packages/…/transactions.ts• L46-83 packages/…/transactions.ts• L117-147 packages/…/types.ts• L45-48 packages/…/types.ts• L81-91

Message signing and sign-in

Message actions use the same capability checks as transaction actions. A connected wallet can expose plain message signatures, version 1 off-chain message signatures, or Sign In With Solana only when it advertises the matching Wallet Standard feature.

verifySignIn() validates the signed input, account, message format, and signature. It supports both the plain sign-in message and the version 1 off-chain message form, so an application can verify the result before it creates an authenticated session.

References: packages/…/wallet-controller.ts• L269-363 packages/…/sign-in.ts• L18-57 packages/…/types.ts• L34-43 packages/…/types.ts• L92-98

Application controls

Wallet selection controls

The UI entry points provide ready-made wallet selection and account controls for common React applications. WalletMultiButton opens the wallet picker before connection, then presents account actions after connection. Headless button hooks expose the same state and actions when an application needs its own design.

The modal provider owns only the visibility of the picker. Wallet choice and connection remain in the wallet provider, so a custom picker and the built-in controls use the same wallet state and operation contracts.

For the full component set and UI behavior, see Wallet UI components.

References: packages/…/WalletMultiButton.tsx• L17-177 packages/…/useWalletButton.ts• L4-84 packages/…/WalletModalProvider.tsx• L21-35 packages/…/package.json• L26-39

Application persistence

The wallet provider can remember the authorized account through configurable storage. The package also exposes useLocalStorage() for small React state that an application wants to persist as JSON. Storage failure does not block in-memory state, and a null value removes the stored value.

Persistence affects reconnect behavior, not the wallet's authorization decision. The wallet still controls whether a stored account can be restored and whether a new connection request succeeds.

References: packages/…/useLocalStorage.ts• L10-65 packages/…/WalletProvider.tsx• L84-117 packages/…/README.md• L48-58

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep the chain used by WalletProvider aligned with the RPC endpoint selected by ConnectionProvider; public endpoint names are checked at transaction send time.
  • Keep capability reporting and operation gating aligned. A newly supported Wallet Standard feature must appear in both the wallet snapshot and the operation that consumes it.
  • Preserve the distinction between selected and connected wallets. UI controls use selection to open a picker and connection state to show account actions.
  • Preserve transaction version checks on every signing path. Direct wallet submission and RPC submission can advertise different Wallet Standard capabilities.
  • Keep the server snapshot disconnected and the browser snapshot subscription-safe so React applications do not depend on wallet discovery during server rendering.
  • Keep the child lifecycle contract in Wallet provider and controller lifecycle aligned with provider configuration, storage, reconnect, and disposal changes.
  • Keep the package exports and peer dependency contract aligned when changing the public React, core, or UI entry points. Applications depend on the package's separate module paths and optional React runtime support.
  • Keep the shared snapshot and operation types aligned when adding a wallet feature. React hooks and core consumers rely on the same contract.

Important failure modes

TriggerConsequenceGuard
useWallet() runs outside WalletProviderThe feature cannot read wallet state and throws WalletConfigError.Place the wallet provider above every component that calls the hook.
useConnection() runs outside ConnectionProviderTransaction features have no RPC connection and throw WalletConfigError.Use the provider hierarchy described above.
The selected wallet is unavailable or no wallet is selectedConnect fails before a wallet authorization request.Rebuild the picker from the current wallets snapshot and select a registered wallet.
A transaction version is not advertised by the connected accountSign or send fails before the wallet is called.Check supportedTransactionVersions for the exact version.
The RPC endpoint names a different public cluster than the wallet chainSubmission fails with a configuration error.Derive both values from the same network setting or use an endpoint whose cluster is not contradictory.
A wallet changes a transaction that contains caller signaturesSubmission fails rather than sending a transaction with changed or lost authorization.Apply local signatures before sending and treat the wallet output as untrusted until the adapter checks it.
The wallet lacks a requested signing featureThe operation is unavailable or fails as not ready.Test the corresponding operation or capability before showing the action.
A consumer imports a module path without its required peer runtimeThe package cannot provide the expected React or wallet integration surface.Use the documented root, core, and ui exports with compatible @solana/kit, @solana/web3.js, React, and React DOM versions.

Key files

FileWhy to read it
packages/…/README.mdGives the supported package surface, provider setup, hook state, transaction behavior, and scope limits.
packages/…/package.jsonDefines the public root, core, UI, and stylesheet exports plus the @solana/kit, @solana/web3.js, and optional React peer contract.
packages/…/index.tsShows the public React and core entry points.
packages/…/ConnectionProvider.tsxDefines the RPC connection context used by transaction-facing features.
packages/…/WalletProvider.tsxConnects the controller to React state and defines the server and browser context boundary.
packages/…/wallet-controller.tsCoordinates discovery, selection, connection, capability checks, signing, submission, errors, and snapshots.
packages/…/types.tsDefines the shared wallet snapshot and operation contract used by React and neutral consumers.
packages/…/transactions.tsDefines the transaction conversion and signature-preservation boundary between web3.js and wallet signing.
packages/…/sign-in.tsDefines verification for plain and off-chain Sign In With Solana results.
packages/…/WalletMultiButton.tsxShows the standard user flow from wallet selection to account actions.
examples/…/providers.tsxShows how an application chooses the network, builds the provider tree, and reports wallet errors.