Next.js Setup
Production-ready Reclaim Protocol integration with Next.js App Router and API routes
✅ Full-Stack Next.js Integration
Leverage Next.js API routes for secure backend initialization while keeping your frontend code clean and simple. Perfect for modern full-stack applications.
Prerequisites
- Next.js 13+ (App Router or Pages Router)
 - API credentials from Reclaim Developer Portal
 
Installation
Install the Reclaim JavaScript SDK:
Project Structure
Or for Pages Router:
Environment Setup
Create .env.local in your project root:
Next.js Environment Variables
- Variables without 
NEXT_PUBLIC_prefix are server-side only (perfect for secrets!) - Variables with 
NEXT_PUBLIC_prefix are exposed to the browser - Never add 
NEXT_PUBLIC_toRECLAIM_APP_SECRET 
Backend API Routes
App Router (Next.js 13+)
Config Route: app/api/reclaim/config/route.js
Callback Route: app/api/reclaim/callback/route.js
Pages Router (Next.js 12 and earlier)
Config API: pages/api/reclaim/config.js
Callback API: pages/api/reclaim/callback.js
Frontend Components
Reusable Verification Component
Create components/ReclaimButton.jsx:
Verification Page
App Router: app/verify/page.jsx
Pages Router: pages/verify.jsx
Local Development
1. Install Dependencies
2. Set Up Environment Variables
Create .env.local with your credentials (see Environment Setup above).
3. Run Development Server
4. Set Up ngrok (for callback testing)
Update .env.local with ngrok URL:
Restart your dev server to pick up the new URL.
5. Test the Integration
Visit http://localhost:3000/verify and click the verification button.
Deployment (Vercel)
1. Push to GitHub
2. Deploy to Vercel
- 
Go to vercel.com and import your repository
 - 
Add environment variables in Vercel dashboard:
RECLAIM_APP_IDRECLAIM_APP_SECRETRECLAIM_PROVIDER_IDNEXT_PUBLIC_BASE_URL(your Vercel URL)
 - 
Deploy!
 
Vercel Auto-Configuration
Vercel automatically sets VERCEL_URL which can be used to construct your callback URL. The code examples above handle this automatically.
Database Integration Example
With Prisma
Common Issues
1. Environment Variables Not Loading
Problem: process.env.RECLAIM_APP_ID is undefined.
Solution:
- Ensure file is named 
.env.local(not.env) - Restart dev server after changing 
.env.local - For server-side vars, don't use 
NEXT_PUBLIC_prefix 
2. Callback Route Not Receiving Data
Problem: Callback endpoint returns 404 or doesn't process proof.
Solutions:
- Verify route file location matches URL structure
 - For App Router: 
app/api/reclaim/callback/route.js - For Pages Router: 
pages/api/reclaim/callback.js - Check 
bodyParseris disabled for Pages Router - Use ngrok for local development
 
3. CORS Issues
Problem: Frontend can't call API routes.
Solution: Next.js API routes automatically handle CORS for same-origin requests. If calling from external domain, add CORS headers:
Next Steps
- Client Integration → - Advanced patterns and hooks
 - Backend Verification → - Deep dive into verification
 - API Reference → - Complete SDK documentation
 - Troubleshooting → - Common issues and solutions