A modern, full-stack web application starter kit that integrates Privy Server wallet authentication with Solana Agent Kit for building secure and scalable web3 applications.
Features
Privy Authentication Server-side authentication using @privy-io/server-auth
for secure user management
Solana Integration Built-in Solana wallet and token management using solana-agent-kit
Next.js 15 Built on the latest Next.js framework with App Router for optimal performance
Database Integration Uses Drizzle ORM with PostgreSQL for type-safe database operations
Modern UI Styled with Tailwind CSS and Radix UI components for a polished look
Rich Text Editing Includes CodeMirror and ProseMirror integration for enhanced editing
Type Safety Full TypeScript support throughout the entire codebase
Testing Configured with Playwright for comprehensive end-to-end testing
Prerequisites
Node.js 18+
pnpm 9.12.3+
PostgreSQL database
Getting Started
Create a new project using gitpick
npx gitpick sendaifun/solana-agent-kit/examples/misc/privy-server-wallet-agent -b v2
cd privy-server-wallet-agent
Set up environment variables
Create a .env
file with the following variables:
# Database
DATABASE_URL=your_postgres_connection_string
# Privy
PRIVY_APP_ID=your_privy_app_id
PRIVY_APP_SECRET=your_privy_app_secret
# Solana
NEXT_PUBLIC_RPC_URL=your_solana_rpc_url
# Optional: OpenAI for AI features
OPENAI_API_KEY=your_openai_api_key
Initialize the database
pnpm db:generate
pnpm db:migrate
Start the development server
Available Scripts
Command Description pnpm dev
Start development server pnpm build
Build for production pnpm start
Start production server pnpm lint
Run linting pnpm format
Format code pnpm test
Run Playwright tests
Database Commands
Command Description pnpm db:generate
Generate database schemas pnpm db:migrate
Run database migrations pnpm db:studio
Open Drizzle Studio pnpm db:push
Push schema changes pnpm db:check
Check schema changes
Project Structure
├── app/ # Next.js app directory
│ ├── api/ # API routes
│ ├── (auth)/ # Authentication routes
│ └── dashboard/ # User dashboard
├── components/ # React components
│ ├── ui/ # UI components
│ ├── forms/ # Form components
│ └── wallet/ # Wallet components
├── lib/ # Utility functions and libraries
│ ├── db/ # Database configuration
│ ├── auth/ # Auth utilities
│ └── solana/ # Solana utilities
├── hooks/ # Custom React hooks
├── public/ # Static assets
├── tests/ # Playwright tests
└── artifacts/ # Build artifacts
Key Integrations
Privy Authentication
This starter uses Privy for authentication, providing:
Social login (Google, Twitter, etc.)
Email and phone authentication
Wallet-based authentication
Server-side session management
Authentication Code Example
// app/providers.tsx
import { PrivyProvider } from '@privy-io/react-auth' ;
import { PrivyWagmiConnector } from '@privy-io/wagmi-connector' ;
export function Providers ({ children } : { children : React . ReactNode }) {
return (
< PrivyProvider
appId = { process . env . NEXT_PUBLIC_PRIVY_APP_ID ! }
config = { {
loginMethods: [ 'email' , 'wallet' ],
appearance: {
theme: 'light' ,
accentColor: '#676FFF' ,
},
embeddedWallets: {
createOnLogin: 'users-without-wallets' ,
},
} }
>
< PrivyWagmiConnector >
{ children }
</ PrivyWagmiConnector >
</ PrivyProvider >
);
}
Solana Agent Kit Integration
The starter comes with Solana Agent Kit pre-configured, allowing users to:
View token balances
Send and receive tokens
Interact with Solana programs
Use AI-powered blockchain interactions
Solana Integration Example
// lib/solana/agent.ts
import { SolanaAgentKit , createVercelAITools } from 'solana-agent-kit' ;
import TokenPlugin from '@solana-agent-kit/plugin-token' ;
import { PublicKey } from '@solana/web3.js' ;
export function createSolanaAgent ( wallet : any ) {
const agent = new SolanaAgentKit (
{
publicKey: new PublicKey ( wallet . publicKey ),
signTransaction: wallet . signTransaction ,
signMessage: wallet . signMessage ,
sendTransaction: wallet . sendTransaction ,
},
process . env . NEXT_PUBLIC_RPC_URL ! ,
{}
). use ( TokenPlugin );
const tools = createVercelAITools ( agent , agent . actions );
return { agent , tools };
}
Database Setup
This starter uses Drizzle ORM with PostgreSQL. The schema is defined in lib/db/schema.ts
:
// lib/db/schema.ts
import { pgTable , serial , text , timestamp , uuid } from 'drizzle-orm/pg-core' ;
export const users = pgTable ( 'users' , {
id: serial ( 'id' ). primaryKey (),
privyUserId: text ( 'privy_user_id' ). notNull (). unique (),
walletAddress: text ( 'wallet_address' ),
email: text ( 'email' ),
createdAt: timestamp ( 'created_at' ). defaultNow (),
updatedAt: timestamp ( 'updated_at' ). defaultNow (),
});
export const transactions = pgTable ( 'transactions' , {
id: uuid ( 'id' ). defaultRandom (). primaryKey (),
userId: serial ( 'user_id' ). references (() => users . id ),
signature: text ( 'signature' ). notNull (),
amount: text ( 'amount' ). notNull (),
tokenAddress: text ( 'token_address' ),
recipient: text ( 'recipient' ). notNull (),
status: text ( 'status' ). notNull (),
createdAt: timestamp ( 'created_at' ). defaultNow (),
});
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the terms of the license included in the LICENSE file.