Reference Nextjs Template
This template is only compatible with@solana/web3.js (legacy, 1.x).
Deploy on Vercel
Deploy your first Solana application on Vercel
Vercel Preview
Try the deployed application
Application Demo
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.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 aSolanaProvider that will be used to provide the Solana context to the
application.
Source Reference
Solana Provider
Wrap the Application in the Solana Provider
Add theSolanaProvider 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
app/page.tsx:
Page