build-app
Build web client application (Next.js, React, Vite)
mkdir -p ~/.claude/commands && curl -fsSL https://raw.githubusercontent.com/solanabr/solana-ai-kit/HEAD/.claude/commands/build-app.md -o ~/.claude/commands/build-app.mdbuild-app.md
You are building a web client application. Follow these steps:
## Related Skills
- [frontend-framework-kit.md](../skills/frontend-framework-kit.md) - React/Next.js patterns
## Step 1: Detect Framework
```bash
echo "🔍 Detecting web framework..."
# Check for Next.js
if grep -q "\"next\"" package.json 2>/dev/null; then
echo "⚡ Next.js project detected"
FRAMEWORK="nextjs"
# Check for Vite
elif [ -f "vite.config.ts" ] || [ -f "vite.config.js" ]; then
echo "⚡ Vite project detected"
FRAMEWORK="vite"
# Check for Create React App
elif grep -q "react-scripts" package.json 2>/dev/null; then
echo "⚛️ Create React App detected"
FRAMEWORK="cra"
# Generic React/Node
elif [ -f "package.json" ]; then
echo "📦 Node.js project detected"
FRAMEWORK="node"
else
echo "❌ No package.json found"
exit 1
fi
```
## Step 2: Install Dependencies
```bash
echo "📦 Installing dependencies..."
# Check for lock files to determine package manager
if [ -f "pnpm-lock.yaml" ]; then
PKG_MANAGER="pnpm"
elif [ -f "yarn.lock" ]; then
PKG_MANAGER="yarn"
elif [ -f "bun.lockb" ]; then
PKG_MANAGER="bun"
else
PKG_MANAGER="npm"
fi
echo "Using package manager: $PKG_MANAGER"
# Install
$PKG_MANAGER install
```
## Step 3: Environment Configuration
```bash
echo "🔧 Checking environment configuration..."
# Check for required env files
if [ -f ".env.example" ] && [ ! -f ".env.local" ]; then
echo "⚠️ Missing .env.local - copying from .env.example"
cp .env.example .env.local
echo "📝 Please update .env.local with your values"
fi
# Verify Solana program ID is set
if grep -q "PROGRAM_ID\|NEXT_PUBLIC_PROGRAM_ID" .env.local 2>/dev/null; then
echo "✅ Program ID configured"
else
echo "⚠️ Warning: No PROGRAM_ID found in environment"
echo " Add: NEXT_PUBLIC_PROGRAM_ID=<your-program-id>"
fi
# Verify RPC endpoint
if grep -q "RPC_URL\|NEXT_PUBLIC_RPC" .env.local 2>/dev/null; then
echo "✅ RPC endpoint configured"
else
echo "ℹ️ Using default RPC endpoint"
fi
```
## Step 4: Type Check (TypeScript)
```bash
echo "📝 Running type check..."
if [ -f "tsconfig.json" ]; then
$PKG_MANAGER run typecheck 2>/dev/null || npx tsc --noEmit
if [ $? -eq 0 ]; then
echo "✅ Type check passed"
else
echo "❌ Type errors found - fix before building"
exit 1
fi
else
echo "ℹ️ No TypeScript config found, skipping type check"
fi
```
## Step 5: Lint Check
```bash
echo "🔍 Running linter..."
if grep -q "eslint" package.json 2>/dev/null; then
$PKG_MANAGER run lint 2>/dev/null || npx eslint . --ext .ts,.tsx,.js,.jsx
if [ $? -eq 0 ]; then
echo "✅ Lint check passed"
else
echo "⚠️ Lint warnings found (non-blocking)"
fi
fi
```
## Step 6: Build Application
```bash
echo "🔨 Building application..."
case $FRAMEWORK in
"nextjs")
echo "Building Next.js app..."
$PKG_MANAGER run build
# Check build output
if [ -d ".next" ]; then
echo "✅ Next.js build successful"
echo ""
echo "📊 Build output:"
du -sh .next
fi
;;
"vite")
echo "Building Vite app..."
$PKG_MANAGER run build
if [ -d "dist" ]; then
echo "✅ Vite build successful"
echo ""
echo "📊 Build output:"
du -sh dist
ls -lh dist
fi
;;
"cra")
echo "Building Create React App..."
$PKG_MANAGER run build
if [ -d "build" ]; then
echo "✅ CRA build successful"
echo ""
echo "📊 Build output:"
du -sh build
fi
;;
*)
echo "Building with default script..."
$PKG_MANAGER run build
;;
esac
```
## Step 7: Verify Build
```bash
echo ""
echo "🔍 Verifying build..."
# Check for common issues
verify_build() {
local build_dir=$1
# Check for source maps in production (security concern)
if find "$build_dir" -name "*.map" | head -1 | grep -q .; then
echo "⚠️ Warning: Source maps found in build"
echo " Consider disabling for production"
fi
# Check bundle sizes
echo ""
echo "📦 Bundle analysis:"
if [ "$FRAMEWORK" = "nextjs" ]; then
# Next.js has built-in bundle analysis
cat .next/build-manifest.json 2>/dev/null | head -20 || true
else
# Generic bundle size check
find "$build_dir" -name "*.js" -exec ls -lh {} \; | head -10
fi
}
case $FRAMEWORK in
"nextjs") verify_build ".next" ;;
"vite") verify_build "dist" ;;
"cra") verify_build "build" ;;
esac
```
## Step 8: Test Build Locally (Optional)
```bash
echo ""
echo "🚀 Testing build locally..."
case $FRAMEWORK in
"nextjs")
echo "Starting Next.js production server..."
echo "Run: $PKG_MANAGER run start"
echo "Then visit: http://localhost:3000"
;;
"vite")
echo "Previewing Vite build..."
echo "Run: $PKG_MANAGER run preview"
echo "Then visit: http://localhost:4173"
;;
"cra")
echo "Serving CRA build..."
echo "Run: npx serve -s build"
echo "Then visit: http://localhost:3000"
;;
esac
```
## Build Summary
```bash
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "✅ BUILD COMPLETE"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
echo "Framework: $FRAMEWORK"
echo "Package Manager: $PKG_MANAGER"
echo ""
echo "📁 Output location:"
case $FRAMEWORK in
"nextjs") echo " .next/" ;;
"vite") echo " dist/" ;;
"cra") echo " build/" ;;
esac
echo ""
echo "💡 Next steps:"
echo " - Test locally: $PKG_MANAGER run start (or preview)"
echo " - Deploy: Connect to Vercel, Netlify, or your hosting"
echo " - Verify program ID matches target network"
```
---
## Common Build Issues
### Missing DependenciesAnchor framework specialist for rapid Solana program development. Use for building programs with Anchor macros, IDL generation, account validation, and standardized patterns. Prioritizes developer experience while maintaining security.\\n\\nUse when: Building new programs quickly, team projects needing standardization, projects requiring IDL for client generation, or when developer experience is prioritized over maximum CU optimization.
DeFi integration specialist for composing with Solana protocols including Jupiter, Drift, Kamino, Raydium, Orca, Meteora, Marginfi, and Sanctum. Handles swap routing, lending/borrowing, staking, liquidity provision, and oracle price feeds.\n\nUse when: Integrating DeFi protocols, building swap interfaces, implementing lending/borrowing, setting up yield strategies, working with Pyth/Switchboard oracles, or composing multi-protocol transactions.
CI/CD, infrastructure, and deployment specialist for Solana projects. Handles GitHub Actions, Docker, monitoring, RPC management, and Cloudflare Workers edge deployment.\n\nUse when: Setting up CI/CD pipelines, containerizing Solana validators or programs, configuring monitoring and alerting, managing RPC infrastructure, deploying edge workers, or automating build and deploy workflows.
Senior Solana game architect for game system design, Unity/C# architecture, on-chain game state, player progression, NFT integration, and PlaySolana ecosystem. Use for high-level game design decisions, architecture reviews, and planning complex game systems.\n\nUse when: Designing new Solana games from scratch, planning game state on-chain, Unity project architecture, integrating with PlaySolana/PSG1, or deciding between implementation approaches.
React Native and Expo specialist for building Solana mobile dApps. Handles mobile wallet adapter integration, transaction signing UX, deep linking, and mobile-specific performance optimization.\n\nUse when: Building React Native or Expo mobile apps with Solana integration, implementing mobile wallet adapter flows, setting up deep links for transaction signing, or optimizing mobile dApp performance.
CU optimization specialist using Pinocchio framework. Use for performance-critical programs requiring 80-95% CU reduction vs Anchor. Specializes in zero-copy access, manual validation, and minimal binary size.\\n\\nUse when: CU limits are being hit, transaction costs are significant at scale, binary size must be minimized, or maximum throughput is required.
Rust backend specialist for building async services that interact with Solana blockchain. Builds APIs, indexing services, and off-chain processing using Axum, Tokio, and modern async patterns.\n\nUse when: Building REST/WebSocket APIs for Solana dApps, implementing transaction indexers, creating webhook services, or any Rust backend that interacts with Solana.
Senior Solana program architect for system design, account structures, PDA schemes, token economics, and cross-program composability. Use for high-level design decisions, architecture reviews, and planning complex multi-program systems.\n\nUse when: Designing new programs from scratch, planning account structures, optimizing PDA schemes, reviewing architecture for security, or deciding between implementation approaches.