Next.js Integration
This guide demonstrates how to integrate Crossmint Auth and Wallets in a Next.js application using the App Router with server-side rendering.Demo Repository
Next.js SSR Demo
Complete working example with authentication and wallet integration
Project Structure
Installation
Environment Variables
Create a.env.local file:
Get your API keys from the Crossmint Console. You need both client-side and server-side keys.
Setup Providers
Create a providers component to wrap your application:Create API Routes
Refresh Token Route
Logout Route
Authentication Helpers
Create a helper function to get the auth session server-side:Login Component
Create a client component for authentication:Main Page
Implement server-side authentication in your page:Middleware (Optional)
Add middleware for protected routes:Next Steps
Add Wallets
Learn how to create and manage wallets
Server-Side Auth
Implement server-side authentication
React Native
Build mobile apps with Crossmint
API Reference
Explore the full API
Troubleshooting
Authentication not working
Authentication not working
- Verify your API keys are correct
- Check that you’re using the right environment (staging vs production)
- Ensure cookies are being set correctly (check browser dev tools)
CORS errors
CORS errors
Make sure your domain is whitelisted in the Crossmint Console under your project settings.
Token refresh issues
Token refresh issues
- Verify the refresh route is configured correctly
- Check that httpOnly cookies are enabled in production
- Ensure the refresh endpoint is accessible