A production-ready React Native mobile application built with Expo that enables users to search and explore Salesforce metadata across any Salesforce organization. This app provides secure OAuth authentication and comprehensive metadata browsing capabilities for administrators, developers, and analysts.
- Framework: React Native with Expo SDK 53
- Language: TypeScript (strict mode)
- Navigation: Expo Router (file-based routing)
- State Management: React Query + @nkzw/create-context-hook
- Authentication: OAuth 2.0 PKCE flow with Expo Auth Session
- Storage: Expo Secure Store for tokens, AsyncStorage for cache
- UI Components: Custom components with Lucide React Native icons
- Platform Support: iOS, Android, and Web (React Native Web)
app/
βββ _layout.tsx # Root layout with providers
βββ index.tsx # App entry point
βββ login.tsx # Login screen
βββ oauth-config.tsx # OAuth configuration modal
βββ (tabs)/ # Tab-based navigation
β βββ _layout.tsx # Tab layout configuration
β βββ search.tsx # Metadata search screen
β βββ export.tsx # Data export functionality
β βββ settings.tsx # App settings
β βββ oauth-education.tsx # OAuth setup guide
β βββ (objects)/ # Object-related screens
β βββ _layout.tsx # Objects stack layout
β βββ list.tsx # Objects list
β βββ [objectName].tsx # Object details
β βββ field-details.tsx # Field details
β βββ metadata-reference.tsx # Metadata references
β βββ picklist-values.tsx # Picklist values
β βββ standard-values.tsx # Standard field values
providers/
βββ auth-provider.tsx # Authentication context
services/
βββ auth.ts # OAuth authentication service
βββ salesforce.ts # Salesforce API service
types/
βββ salesforce.ts # TypeScript type definitions
constants/
βββ standard-field-values.ts # Standard field configurations
- OAuth Flow: PKCE (Proof Key for Code Exchange) - secure for mobile apps
- Scopes:
api,refresh_token,openid,profile,email - Redirect URI:
myapp://oauth/callback(mobile),http://localhost/oauth/callback(web) - Storage: Tokens stored securely in Expo Secure Store
- Configuration: User enters Consumer Key and Instance URL
- Authorization: App redirects to Salesforce login page
- Code Exchange: Authorization code exchanged for access/refresh tokens
- Token Storage: Tokens stored securely with expiration tracking
- Auto-Refresh: Automatic token refresh when expired
- User Info: Fetch user profile and organization details
interface Tokens {
accessToken: string;
refreshToken: string;
issuedAt: number; // Timestamp when token was issued
expiresIn: number; // Token lifetime in seconds
authHost: string; // Salesforce instance URL
instanceUrl: string; // API endpoint URL
idToken?: string; // OpenID Connect token
}- Expiry Check: Tokens expire after
expiresInseconds with 5-minute buffer - Auto-Refresh: Automatic refresh when token is expired
- Error Handling: Graceful handling of refresh failures with re-authentication prompts
- Session Management: Clear invalid tokens and prompt for re-login
- Objects:
/services/data/v64.0/sobjects/- List all objects - Fields:
/services/data/v64.0/sobjects/{object}/describe/- Object field metadata - Tooling API:
/services/data/v64.0/tooling/query/- Metadata queries - Search:
/services/data/v64.0/search/- SOSL searches - User Info:
/services/oauth2/userinfo- User profile data - Organization:
/services/data/v64.0/query/- Organization details
- Standard Objects: Account, Contact, Opportunity, etc.
- Custom Objects: User-defined objects (ending with
__c) - Fields: All field types including custom fields
- Apex Classes: Server-side code components
- Apex Triggers: Database trigger code
- Flows: Process automation workflows
- Validation Rules: Data validation logic
- Record Types: Object record categorization
- Page Layouts: UI layout definitions
- Aura Components: Lightning component bundles
- Lightning Web Components: Modern component framework
- Code Content Search: Full-text search within Apex classes and triggers
- SOSL Integration: Salesforce Object Search Language queries
- Metadata References: Find where fields are referenced across metadata
- Line-by-Line Results: Show exact line numbers and code snippets
- Multi-Type Search: Search across multiple metadata types simultaneously
- Input Validation: Minimum 2 characters required
- Parallel Execution: Multiple search types run concurrently
- Content Analysis: Line-by-line code analysis with regex matching
- Result Aggregation: Combine results from different metadata types
- Relevance Sorting: Sort by match count and alphabetical order
// Main search function
export async function searchCodeContent(
instanceUrl: string,
accessToken: string,
searchTerm: string
): Promise<CodeSearchResult[]>;
// Search types executed in parallel:
// 1. Apex Classes - body content search
// 2. Apex Triggers - body content search
// 3. Flows - name and label search
// 4. SOSL - broad metadata search- Timeout Handling: 10-second timeout per search type
- Result Limiting: Maximum 50 results per search type
- Concurrent Execution: Parallel Promise execution
- Error Isolation: Individual search failures don't break entire search
- Caching: Results cached for improved performance
interface AuthState {
accessToken: string | null;
refreshToken: string | null;
instanceUrl: string | null;
userInfo: UserInfo | null;
isAuthenticated: boolean;
isLoading: boolean;
}- AuthProvider: Global authentication state and methods
- QueryClient: React Query for server state management
- GestureHandler: Touch gesture handling
- Authentication: OAuth tokens managed in AuthProvider
- API Calls: React Query mutations for server requests
- Local Storage: Secure token storage and cache management
- Error Handling: Token expiration and network error recovery
- Color Palette: Salesforce Lightning Design System inspired
- Typography: System fonts with proper weight hierarchy
- Icons: Lucide React Native icon library
- Layout: Tab-based navigation with stack navigation
- Responsive: Adaptive design for different screen sizes
Root Stack
βββ Tabs (Main App)
β βββ Objects Tab
β β βββ Objects List
β β βββ Object Details
β β βββ Field Details
β β βββ Metadata References
β βββ Search Tab
β βββ Export Tab
β βββ OAuth Education Tab
β βββ Settings Tab
βββ Login Screen (Modal)
βββ OAuth Config (Modal)
- Search Interface: Real-time search with highlighted results
- Metadata Cards: Organized display of metadata information
- Code Snippets: Syntax-highlighted code with line numbers
- Loading States: Proper loading indicators and error states
- Tab Bar: Custom-styled bottom navigation
-
Connected App Creation:
- Go to Setup β App Manager β New Connected App
- Enable OAuth Settings
- Add Callback URL:
myapp://oauth/callback - Select Scopes:
api,refresh_token,openid,profile,email - Enable PKCE (uncheck "Require Secret for Web Server Flow")
- Set IP Relaxation to "Relax IP restrictions"
-
Consumer Key: Copy the Consumer Key (no secret needed for PKCE)
-
Instance URL: Configure for your Salesforce environment
- Production:
https://login.salesforce.com - Sandbox:
https://test.salesforce.com - Custom Domain:
https://yourdomain.my.salesforce.com
- Production:
- Launch the app and go to Settings β OAuth Configuration
- Enter Consumer Key from your Connected App
- Set Instance URL for your Salesforce environment
- Save configuration and return to login
- Authenticate with your Salesforce credentials
- No hardcoded credentials: All authentication details configured by user
- Secure token storage: OAuth tokens stored in device secure storage
- No data collection: App doesn't collect or transmit personal data
- Local processing: All metadata analysis happens on device
- Salesforce APIs only: Communicates exclusively with Salesforce APIs
This app is designed to be production-ready:
- No hardcoded instance URLs or organization-specific data
- Configurable OAuth settings for any Salesforce org
- Secure authentication flow with automatic token refresh
- Cross-platform compatibility (iOS, Android, Web)
- Comprehensive error handling and user feedback
- iOS: Full native support with proper safe area handling
- Android: Full native support with material design elements
- Web: React Native Web compatibility with fallbacks for unsupported APIs
- Expo APIs: Limited web support for some Expo modules
- Secure Store: Falls back to localStorage on web
- Haptics: Disabled on web platform
- Navigation: Proper URL routing for web
{
"expo": {
"name": "Salesforce Metadata Search",
"scheme": "myapp",
"platforms": ["ios", "android", "web"],
"plugins": ["expo-router", "expo-secure-store"]
}
}- Secure Token Storage: Expo Secure Store for sensitive data
- PKCE Flow: Secure OAuth without client secrets
- Token Expiration: Automatic token refresh and cleanup
- Error Handling: Secure error messages without exposing sensitive data
- HTTPS Only: All API calls use HTTPS
- Token Validation: Server-side token validation
- Scope Limitation: Minimal required OAuth scopes
- Session Management: Proper session cleanup on logout
- Authentication Errors: Token expiration, invalid credentials
- Network Errors: Connection timeouts, API failures
- Data Errors: Invalid responses, parsing failures
- User Errors: Invalid input, configuration issues
- Automatic Retry: Failed requests automatically retried
- Token Refresh: Expired tokens automatically refreshed
- Graceful Degradation: Partial failures don't break entire app
- User Feedback: Clear error messages and recovery instructions
- Console Logging: Comprehensive logging for debugging
- Error Tracking: Structured error information
- Performance Monitoring: API response times and success rates
- Authentication Flow: OAuth PKCE implementation
- API Integration: Salesforce API calls and responses
- Search Functionality: Metadata search accuracy
- Error Handling: Network failures and token expiration
- UI Components: User interface interactions
- Unit Tests: Component and service testing
- Integration Tests: API integration testing
- E2E Tests: Full user flow testing
- Platform Testing: iOS, Android, and Web compatibility
- Lazy Loading: Components loaded on demand
- Result Pagination: Limited results per search
- Caching: API response caching
- Debouncing: Search input debouncing
- Memory Management: Proper cleanup of resources
- API Response Times: Track Salesforce API performance
- Search Performance: Monitor search execution times
- Memory Usage: Track app memory consumption
- User Experience: Monitor app responsiveness
- Offline Support: Cache metadata for offline access
- Advanced Filters: More sophisticated search filters
- Export Functionality: Export search results to various formats
- Metadata Comparison: Compare metadata across orgs
- Bulk Operations: Batch metadata operations
- Performance Optimization: Further search performance improvements
- UI Enhancements: More polished user interface
- Error Recovery: Enhanced error handling and recovery
- Testing Coverage: Comprehensive test suite
- Documentation: Enhanced user and developer documentation
This architecture provides a robust, scalable, and secure foundation for Salesforce metadata exploration and search functionality across multiple platforms.