
Capacitor Best Practices
Structure, harden, and optimize a Capacitor hybrid app from first scaffold through store-ready review.
Overview
capacitor-best-practices is an agent skill most often used in Build (also Ship, Launch) that applies Capgo’s guidelines for Capacitor structure, plugins, performance, security, and deployment readiness.
Install
npx skills add https://github.com/cap-go/capacitor-skills --skill capacitor-best-practicesWhat is this skill?
- Recommended monorepo-style layout: `src/`, `android/`, `ios/`, `capacitor.config.ts`
- Plugin usage patterns aligned with official Capacitor and Ionic docs
- Performance optimization checklist for hybrid WebView apps
- Security hardening and production error-handling guidance
- Live updates and deployment preparation for app store submission
- Guide version 1.0.0 (Capgo, January 2026)
- Documented layout includes src/, android/, ios/, capacitor.config.ts
Adoption & trust: 908 installs on skills.sh; 45 GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
Your Capacitor app grew messy—unclear native layout, plugin sprawl, slow WebView, or weak security—and you lack a single review checklist before stores.
Who is it for?
Indie devs and small teams building Ionic or web-first apps wrapped with Capacitor for iOS and Android.
Skip if: Pure native Swift/Kotlin apps with no WebView layer or greenfield React Native projects outside Capacitor.
When should I use this skill?
Capacitor best practice, optimize capacitor, capacitor security, capacitor performance, capacitor project structure, or review capacitor code.
What do I get? / Deliverables
You align the project with recommended structure and hardening steps so the hybrid app is faster, safer, and closer to app-store submission.
- Aligned directory and config structure
- Performance and security review outcomes
- Deployment-readiness notes for store submission
Recommended Skills
Journey fit
Spans multiple journey phases - primary shelf plus alternate fits below.
Most guidance applies while you are building the web-plus-native shell, with follow-on use during ship review and launch prep. Capacitor centers the web layer in `src/` with native `android/` and `ios/` projects—classic build-phase frontend/mobile integration work.
Where it fits
Lay out `src/`, native projects, and `capacitor.config.ts` before adding custom plugins.
Run a capacitor code review for plugin usage, error handling, and performance hotspots.
Validate deployment preparation and security measures ahead of Play/App Store submission.
How it compares
Opinionated Capgo best-practices skill—not a replacement for reading capacitorjs.com docs or automated mobile CI pipelines alone.
Common Questions / FAQ
Who is capacitor-best-practices for?
Solo and indie builders shipping hybrid mobile apps with Capacitor who want a single skill for structure, security, and performance reviews.
When should I use capacitor-best-practices?
In Build when setting up or restructuring a Capacitor repo; in Ship when reviewing code and optimizing WebView performance; in Launch when preparing security and deployment for app store submission.
Is capacitor-best-practices safe to install?
Treat it as advisory patterns; review the Security Audits panel on this Prism page for the cap-go repo before installing.
SKILL.md
READMESKILL.md - Capacitor Best Practices
{ "version": "1.0.0", "organization": "Capgo", "date": "January 2026", "abstract": "Comprehensive best practices guide for Capacitor app development. Covers project structure, plugin usage patterns, performance optimization, security hardening, error handling, live updates, and deployment preparation.", "triggers": [ "capacitor best practice", "optimize capacitor", "capacitor security", "capacitor performance", "capacitor project structure", "review capacitor code" ], "references": [ "https://capacitorjs.com/docs", "https://capgo.app/docs", "https://ionicframework.com/docs" ] } --- name: capacitor-best-practices description: 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. --- # 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 ```text my-app/ ├── src/ # Web app source ├── android/ # Android native project ├── ios/ # iOS native project ├── capacitor.config.ts # Capacitor configuration ├── package.json └── tsconfig.json ``` ### Configuration Best Practices **capacitor.config.ts** (CORRECT): ```typescript import type { CapacitorConfig } from '@capacitor/cli'; const config: CapacitorConfig = { appId: 'com.company.app', appName: 'My App', webDir: 'dist', server: { // Only enable for development ...(process.env.NODE_ENV === 'development' && { url: 'http://localhost:5173', cleartext: true, }), }, plugins: { SplashScreen: { launchAutoHide: false, }, }, }; export default config; ``` **capacitor.config.json** (AVOID): ```json { "server": { "url": "http://localhost:5173", "cleartext": true } } ``` *Never commit development server URLs to production* ## Plugin Usage ### CRITICAL: Always Use Latest Capacitor Keep Capacitor core packages in sync: ```bash npm install @capacitor/core@latest @capacitor/cli@latest npm install @capacitor/ios@latest @capacitor/android@latest npx cap sync ``` ### Plugin Installation Pattern **CORRECT**: ```bash # 1. Install the package npm install @capgo/capacitor-native-biometric # 2. Sync native projects npx cap sync # 3. For iOS: Install pods (or use SPM) cd ios/App && pod install && cd ../.. ``` **INCORRECT**: ```bash # Missing sync step npm install @capgo/capacitor-native-biometric # App crashes because native code not linked ``` ### Plugin Initialization **CORRECT** - Check availability before use: ```typescript import { NativeBiometric, BiometryType } from '@capgo/capacitor-native-biometric'; async function authenticate() { const { isAvailable, biometryType } = await NativeBiometric.isAvailable(); if (!isAvailable) { // Fallback to password return authenticateWithPassword(); } try { await NativeBiometric.verifyIdentity({ reason: 'Authenticate to access your account', title: 'Biometric Login', }); return true; } catch (error) { // User cancelled or biometric failed return false; } } ``` **INCORRECT** - No availability check: ```typescript // Will crash if biometrics not available await NativeBiometric.verifyIdentity({ reason: 'Login' }); ``` ## Performance Optimization ### CRITICAL: Lazy Load Plugins **CORRECT** - Dynamic imports: ```typescript // Only load when needed async function scanDocument() { const { DocumentScanner } = await import('@capgo/capacitor-document-scanner'); return DocumentScanner.scanDocument(); } ``` **INCORRECT** - Import everyth