Adapter Configuration
Configure service adapters to switch between mock implementations and production services.Understanding Adapters
The starter uses an adapter pattern for key services:- Authentication - Mock or Firebase
- Subscriptions - Mock or RevenueCat
- Analytics - Mock or Firebase
- Develop without production services
- Switch providers easily
- Test with mock data
- Use different adapters per environment
Configuration Files
Adapters are configured in two places:amisi.config.json- Adapter selectionpackages/config/src/flags.ts- Feature flags to enable/disable services
Authentication Adapter
Available Adapters
mock- Simulated authentication (development)firebase- Firebase Authentication (production)
Configure in amisi.config.json
Mock Adapter
The mock adapter provides simulated authentication:- No external dependencies
- Instant sign-in/sign-up
- Simulated user sessions
- Perfect for development
- No real authentication
- Data not persisted
- No password validation
Firebase Adapter
The Firebase adapter uses Firebase Authentication:- Firebase project configured
GoogleService-Info.plist(iOS)google-services.json(Android)- Environment variables set
- Email/password authentication
- Social sign-in (Google, Apple, etc.)
- Password reset
- Email verification
- Multi-factor authentication
- Follow Firebase Setup guide
- Set environment variables
- Enable authentication methods in Firebase Console
- Rebuild native projects
Subscriptions Adapter
Available Adapters
mock- Simulated subscriptions (development)revenuecat- RevenueCat (production)
Configure in amisi.config.json
Mock Adapter
The mock adapter provides simulated subscriptions:- No external dependencies
- Simulated products
- Instant purchases
- Simulated subscription status
- No real payments
- No App Store/Play Store integration
- Data not persisted
RevenueCat Adapter
The RevenueCat adapter integrates with RevenueCat for subscription management:- RevenueCat account
- App configured in RevenueCat dashboard
- API keys set in environment variables
- Products configured in App Store Connect / Google Play Console
- Real subscription purchases
- Cross-platform subscription management
- Receipt validation
- Subscription analytics
- Webhooks for server-side events
- Create RevenueCat account
- Add your app to RevenueCat dashboard
- Configure products in App Store Connect / Google Play Console
- Link products in RevenueCat
- Set environment variables:
- Rebuild native projects
Analytics Adapter
Available Adapters
mock- No-op analytics (development)firebase- Firebase Analytics + Crashlytics (production)
Configure with Feature Flags
Analytics is controlled by feature flags inpackages/config/src/flags.ts:
Mock Adapter
When analytics is disabled, the mock adapter is used:- No external dependencies
- Silent (no-op)
- No network requests
- Developing locally
- Testing without analytics
- Running in Expo Go
Firebase Adapter
When analytics is enabled, the Firebase adapter is used:- Firebase project configured
GoogleService-Info.plist(iOS)google-services.json(Android)- Native build (not Expo Go)
- Firebase Analytics (GA4)
- Firebase Crashlytics
- Automatic screen tracking
- Custom event tracking
- User properties
- Crash reporting
- Follow Firebase Setup guide
- Enable feature flags
- Rebuild native projects
Environment-Specific Configuration
Use different adapters for different environments:Development
Preview
Production
Testing Adapter Changes
After changing adapters:-
Update configuration files:
amisi.config.jsonpackages/config/src/flags.ts
-
Set environment variables (if using production adapters):
- Firebase variables
- RevenueCat variables
-
Rebuild native projects (if using Firebase or RevenueCat):
-
Restart development server:
-
Test functionality:
- Sign in/sign up (auth)
- View products (subscriptions)
- Navigate screens (analytics)
Adapter Initialization
Adapters are initialized at app startup inapps/mobile/app/_layout.tsx:
Authentication
Subscriptions
Analytics
Creating Custom Adapters
You can create custom adapters for other services:1. Implement the Adapter Interface
2. Register the Adapter
3. Use the Adapter
Common Issues
Adapter Not Found
Error:Adapter 'firebase' not found
Solution: Ensure the adapter is registered and dependencies are installed.
Initialization Failed
Error:Failed to initialize adapter
Solution: Check that:
- Environment variables are set
- Config files are in place (Firebase)
- Native projects are rebuilt
Mock Adapter in Production
Warning: Never use mock adapters in production builds. Solution: Verifyamisi.config.json and feature flags for production environment.
Best Practices
- Use mock adapters for development - Faster iteration, no external dependencies
- Test with production adapters before release - Catch integration issues early
- Use environment-specific configuration - Different adapters per environment
- Keep secrets secure - Use EAS Secrets for production API keys
- Document adapter requirements - Make it clear what’s needed for each adapter