Skip to main content
Security is critical for mobile applications. This guide covers essential security practices to protect your React Native app and user data.

Data Storage Security

Secure Storage

Never store sensitive data in AsyncStorage, which is unencrypted.

Use Encrypted Storage

Keychain/Keystore

For tokens and passwords, use platform-specific secure storage:
Never store passwords or API keys in plain text. Always use encrypted storage or keychain/keystore services.

What NOT to Store in AsyncStorage

Network Security

HTTPS Only

Always use HTTPS for API calls:

Certificate Pinning

Prevent man-in-the-middle attacks by pinning certificates:

API Key Protection

Never hardcode API keys in your JavaScript code:
Setup .env:
Add to .gitignore:
For highly sensitive keys, use backend proxy servers instead of including them in the app.

Request Authentication

Token Refresh

Authentication

Biometric Authentication

OAuth 2.0 / Social Login

Input Validation

Sanitize User Input

Validate Forms

Prevent XSS

Code Obfuscation

JavaScript Obfuscation

metro.config.js:
Obfuscation makes code harder to read but doesn’t make it completely secure. Never rely solely on obfuscation.

ProGuard (Android)

android/app/build.gradle:
android/app/proguard-rules.pro:
Use universal/app links instead of custom URL schemes for better security. iOS ios/MyApp/MyApp.entitlements:
Android android/app/src/main/AndroidManifest.xml:

Permissions

Request Only Necessary Permissions

iOS ios/MyApp/Info.plist:

Jailbreak/Root Detection

Jailbreak/root detection can be bypassed. Use it as one layer of defense, not the only security measure.

Secure Coding Practices

Avoid Console Logs in Production

Remove Debug Code

Secure Random Number Generation

Security Checklist

  • Use EncryptedStorage for sensitive data
  • Use Keychain/Keystore for credentials
  • Never store passwords in plain text
  • Clear sensitive data on logout
  • Implement secure data migration
  • Use HTTPS for all API calls
  • Implement certificate pinning
  • Store API keys securely
  • Implement token refresh
  • Validate SSL certificates
  • Handle network errors securely
  • Implement secure login
  • Use biometric authentication
  • Implement session management
  • Handle token expiration
  • Implement secure logout
  • Use OAuth for social login
  • Obfuscate production code
  • Enable ProGuard (Android)
  • Remove debug code
  • Validate all user input
  • Implement error handling
  • Use TypeScript for type safety
  • Implement jailbreak detection
  • Request minimal permissions
  • Validate deep links
  • Implement rate limiting
  • Use secure random generation
  • Regular security audits

Testing Security

Automated Security Testing

Manual Testing

  1. Test with HTTP Proxy: Burp Suite, Charles Proxy
  2. Test on jailbroken/rooted devices
  3. Test with mock data
  4. Test error scenarios
  5. Test session timeout

Security Resources

Next Steps

Publishing

Publish your secure app to stores

Troubleshooting

Debug security-related issues