capacitor-best-practices
Best practices for Capacitor app development including project structure, plugin usage, performance optimization, security, and deployment. Use this skill when reviewing Capacitor code, setting up new projects, or optimizing existing apps.
By cap-go · 2,226 installs
npx skills add cap-go/capgo-skills --skill capacitor-best-practices
Source repository · Upstream listing
Capacitor Best Practices
Comprehensive guidelines for building production ready Capacitor applications.
When to Use This Skill
Setting up a new Capacitor project
Reviewing Capacitor app architecture
Optimizing app performance
Implementing security measures
Preparing for app store submission
Project Structure
Recommended Directory Layout
Configuration Best Practices
capacitor.config.ts (CORRECT):
capacitor.config.json (AVOID):
Never commit development server URLs to production
Plugin Usage
CRITICAL: Always Use Latest Capacitor
Keep Capacitor core packages in sync:
Plugin Installation Pattern
CORRECT :
INCORRECT :
Plugin Initialization
CORRECT Check availability before use:
INCORRECT No availability check:
Performance Optimization
CRITICAL: Lazy Load Plugins
CORRECT Dynamic imports:
INCORRECT Import everything at startup:
HIGH: Optimize WebView Performance
CORRECT Use hardware acceleration:
HIGH: Minimize Bridge Calls
CORRECT Batch operations:
INCORRECT Multiple bridge calls:
MEDIUM: Image Optimization
CORRECT :
INCORRECT :
Security Best Practices
CRITICAL: Secure Storage
CORRECT Use secure storage for sensitive data:
INCORRECT Plain storage:
CRITICAL: Certificate Pinning
For production apps handling sensitive data:
HIGH: Root/Jailbreak Detection
HIGH: App Tracking Transparency (iOS)
Error Handling
CRITICAL: Always Handle Plugin Errors
CORRECT :
INCORRECT :
Live Updates
Using Capacitor Updater
Update Strategy
CORRECT Background download, apply on restart:
INCORRECT Interrupt user:
Native Project Management
iOS: Use Swift Package Manager (SPM)
Modern approach prefer SPM over CocoaPods:
Android: Gradle Configuration
Testing
Plugin Mocking
Platform Detection
Deployment Checklist
[ ] Remove development server URLs from config
[ ] Enable ProGuard for Android release builds
[ ] Set appropriate iOS deployment target
[ ] Test on real devices, not just simulators
[ ] Verify all permissions are declared
[ ] Test with poor network conditions
[ ] Verify deep links work correctly
[ ] Test app backgrounding/foregrounding
[ ] Verify push notifications work
[ ] Test biometric authentication edge cases
Resources
Capacitor Documentation: https://capacitorjs.com/docs
Capgo Documentation: https://capgo.app/docs
Ionic Framework: https://ionicframework.com/docs