This is a template for integrating Privy's Solana capabilities into a Next.js application. It provides a simple setup for wallet login, embedded wallets, and transaction signing using the Privy React SDK.
This demo uses NextJS's App Router.
- Clone this repository and open it in your terminal.
git clone https://github.com/privy-io/create-next-solana-app.git && cd create-next-solana-app- Install the dependencies.
npm install- Define the environment variables in a
.env.localfile.
cp .env.local.example .env.localIn your project directory, run npm run dev. You can now visit http://localhost:3000 to see your app and login with Privy!
components/providers.tsxfor how to use thePrivyProviderand initialize it with your Privy App ID.app/page.tsxfor how to verify if a user is logged in from a server component.components/loginButton.tsxfor how to use theuseLoginPrivy hook to log in a user and create an embedded wallet.app/dashboard/page.tsxfor how to use theusePrivyhook to access the Privy SDK in a client component, and how to use the embedded and EOA wallets to sign a message and send a transaction.