Frontend Example with React
This guide will walk you through the fundamental steps to integrate Reclaim's proof verification system into your React application.
Prerequisites
Before implementing Reclaim verification in your React application, ensure you have:
- Successfully installed the Reclaim SDK (refer to the Installation Guide)
- Obtained the following credentials for initializing your Application from Reclaim Developer Portal:
- Application ID
- Application Secret
- Provider ID
โ ๏ธ Security Warning: Using your Application Secret in client-side code should be limited to prototyping only. For production environments, always store your secret securely on a backend server and never expose it in frontend code.
Implementation Guide
The following example demonstrates how to create a React component that implements Reclaim verification with QR code functionality:
Implementation Breakdown
1. Component Structure
- Manages state for verification URL and proofs
- Handles verification requests
- Renders user interface elements
2. Verification Flow
- Initializes SDK with credentials on button click
- Generates and stores request URL
- Monitors for proof submissions
- Processes success/error states
3. Response Types
- String: When using custom callback URLs
- Object: When using default callback handling
Integration Steps
- Component Integration
- Environment Setup
- Store your credentials securely
- Configure error handling
- Set up appropriate loading states
๐ก Device Detection Tip: Consider implementing device detection to optimize the user experience:
- Desktop: Display QR code for mobile scanning
- Mobile: Show direct verification link or better yet, use the appClip/Instant App flow from Advance Options
๐ Production Security Requirements:
- Never expose APP_SECRET in frontend code
- Generate request configurations server-side as shown in Fullstack Example
- Use
fromJsonString()
method in frontend code to initialize the SDK - Implement proper error handling and validation
Refer to the Fullstack Example for secure implementation details.
Next Steps
After implementing the basic verification:
-
Advance Options
- Explore Advance Options for more fine-tuned customization of your implementation
-
Testing
- Test across different devices and browsers
- Verify error scenarios and validate security measures
Support Resources
- View complete working example: demo repository
- Join our Telegram community for support
- Consult the API documentation for detailed reference
Remember to regularly update your implementation as new SDK versions are released to ensure optimal security and performance.