Skip to content
Polski
Solana’s wallet-adapter library makes it easy to manage wallet connections with a frontend application.

​Reference Nextjs Template

This template is only compatible with @solana/web3.js (legacy, 1.x). Deploy your first Solana application - a simple Counter Program built using the Anchor framework. This example covers all the core Solana concepts to get started building on Solana. View the source code here.

Application Demo

For a @solana/kit example, reference the Kit example.

​Dependencies

@solana/web3.js 1.x is no longer actively maintainedIt receives critical fixes only. Use Kit for new code. To migrate existing code, follow the Kit upgrade guide, or the web3.js v3 migration guide to keep the class-based API.To run this code, install 1.x with npm install @solana/web3.js@1. A plain npm install @solana/web3.js installs v3, which this code doesn’t run on.
If you are creating a new Nextjs project, install the following dependencies:
Terminal
This example uses Wallet Standard discovery with wallets={[]}, so it does not need the @solana/wallet-adapter-wallets bundle. That bundle includes legacy adapters and can install deprecated WalletConnect v1 dependencies. If you need WalletConnect protocol support specifically, use Reown’s Solana Adapter.

​Create Solana Provider

Create a SolanaProvider that will be used to provide the Solana context to the application. Source Reference
Solana Provider

​Wrap the Application in the Solana Provider

Add the SolanaProvider to the RootLayout in the app directory. Source Reference
Root Layout

​Add a Connect Button

WalletMultiButton opens a modal that lists the wallets the browser has installed, connects the one the user picks, and then shows the connected address with options to copy it, change wallet, or disconnect. Read the connection anywhere inside SolanaProvider with useWallet(): publicKey is null until a wallet connects. Save this component as components/WalletButton.tsx:
Wallet Button
Render it on a page inside the provider, for example app/page.tsx:
Page