Capacitor
20 minutes
linux
macos
windows

What is Capacitor?

Learn what Capacitor is, how it turns web apps into native mobile apps, and when to use it.

What you'll accomplish

Understand what Capacitor is and decide if it's right for your project.

Prerequisites

  • Basic understanding of web development (HTML, CSS, JavaScript)
  • Familiarity with React or Next.js helpful but not required

What is Capacitor?

Capacitor is a tool that wraps your web application in a native container, allowing it to run as a real iOS or Android app. Your web code (HTML, CSS, JavaScript) stays the same - Capacitor handles the native parts.

Imagine you have a present (your web app). Capacitor is like gift-wrapping paper:

  • The present inside stays exactly the same
  • But now it's in a package that can be delivered to the App Store
  • And it gets special labels (native features) that make it work better

Your website becomes an app that people can download from app stores, with access to camera, GPS, push notifications, and more.

How It Works

Your Web App (HTML, CSS, JS)
         │
         ▼
   ┌──────────────┐
   │  Capacitor   │
   │   Runtime    │
   └──────────────┘
         │
    ┌────┴────┐
    ▼         ▼
┌──────┐  ┌──────────┐
│ iOS  │  │ Android  │
│ App  │  │   App    │
└──────┘  └──────────┘
  1. You build your web app normally
  2. Capacitor wraps it in a native WebView
  3. Plugins provide access to native features
  4. You build real .ipa (iOS) and .apk (Android) files

Capacitor vs. Other Approaches

Capacitor vs. React Native

AspectCapacitorReact Native
CodeStandard HTML/CSS/JSReact components that compile to native
Learning curveLower (use existing skills)Higher (new paradigms)
PerformanceGood (WebView)Better (native rendering)
UIWeb UI (same everywhere)Native UI (platform-specific)
Existing codeReuse your web appRewrite from scratch
Team skillsWeb developersReact + native knowledge

Choose Capacitor when:

  • You have an existing web app to convert
  • Your team knows web technologies
  • Consistent UI across platforms is desired
  • You need to ship quickly

Choose React Native when:

  • Performance is critical (games, animations)
  • You want fully native UI
  • You're starting from scratch
  • You have React Native experience

Capacitor vs. PWA

AspectCapacitorPWA
App StoreYesNo (mostly)
Native featuresFull accessLimited
InstallationDownload from store"Add to Home Screen"
UpdatesStore approval neededInstant
DiscoverabilityApp Store searchWeb search

Choose Capacitor when:

  • You need App Store presence
  • Push notifications are important
  • You need deep native integration
  • Users expect a "real" app

Choose PWA when:

  • Instant updates are critical
  • You want to skip app store approval
  • Basic native features are enough
  • Lower friction installation matters

What Can You Build?

Capacitor works great for:

App TypeWhy It Works
Business appsForms, dashboards, data entry
E-commerceProduct catalogs, checkout flows
Social appsFeeds, messaging, profiles
ProductivityTask lists, notes, calendars
Media appsPhoto galleries, video players
Utility appsCalculators, converters, tools

Capacitor is less ideal for:

App TypeWhy It's Challenging
GamesWebView not optimized for graphics
AR/VRLimited access to AR frameworks
Heavy animationMay not hit 60fps consistently
Offline-firstPossible but complex

Native Features via Plugins

Capacitor provides access to native features through plugins:

Official Plugins

PluginWhat It Does
CameraTake photos, record video
GeolocationGet GPS coordinates
Push NotificationsReceive push messages
StorageLocal data persistence
FilesystemRead/write files
ShareNative share sheet
HapticsVibration feedback
NetworkConnection status
AppApp state, deep links
Splash ScreenLoading screen control

Community Plugins

Hundreds of community plugins for:

  • Social logins (Google, Apple, Facebook)
  • In-app purchases
  • Analytics
  • Bluetooth
  • Barcode scanning
  • And much more

Using a Plugin

typescript
import { Camera, CameraResultType } from '@capacitor/camera';

async function takePicture() {
  const image = await Camera.getPhoto({
    quality: 90,
    allowEditing: true,
    resultType: CameraResultType.Uri
  });

  // image.webPath contains the photo
  return image.webPath;
}

The same code works on iOS and Android!

Requirements

To use Capacitor, you'll need:

For Development

  • Node.js 18+
  • npm or yarn
  • A web framework (Next.js, React, Vue, etc.)

For iOS Builds

  • A Mac (required - Apple restriction)
  • Xcode 15+ (free from App Store)
  • Apple Developer account ($99/year for App Store)

For Android Builds

  • Android Studio (free, any OS)
  • JDK 17+
  • Google Play Developer account ($25 one-time for Play Store)
Note

No Mac? You can still develop and test on Android. For iOS, you'll need access to a Mac eventually, or use a cloud service like MacStadium or GitHub Actions.

Is Capacitor Right for You?

Yes, if:

  • You have a working web app you want on app stores
  • Your team has web development skills
  • You value code reuse and maintenance simplicity
  • Your app is content/data focused (not graphics-heavy)
  • You want to target iOS and Android with one codebase

Maybe not, if:

  • Performance is critical (games, heavy animations)
  • You need the absolute native look and feel
  • You're building only for one platform
  • You have experienced native developers

Apps built with Capacitor (or its predecessor Ionic):

  • Sworkit - Fitness app with millions of users
  • MarketWatch - Financial news app
  • Papa Johns - Pizza ordering app
  • NHS - UK National Health Service apps

These companies chose Capacitor because they could leverage their web teams and existing code while still delivering native app experiences.

Common Questions

Frequently Asked Questions

For most apps, no. Capacitor apps feel native because they ARE native - they run in a native container with access to native features. Performance-sensitive transitions might reveal WebView behavior, but this is rarely noticeable in typical apps.

Yes! Capacitor works with any web framework:

  • Next.js (with static export)
  • React
  • Vue
  • Angular
  • Svelte
  • Plain HTML/CSS/JS

For basic apps, no. Plugins handle native code. For advanced customization, you might write small amounts of native code, but it's optional.

Two options:

  1. App Store update: Full release process (days to approve)
  2. Live Update plugins: Update web content without store approval (instant)

Many teams use live updates for content changes and store updates for native code changes.

Capacitor adds some overhead (the WebView runtime). Typical apps are 10-30MB, which is acceptable for most users. Heavy assets (images, videos) affect size more than Capacitor itself.

Next Steps

Ready to try Capacitor? Here's the path:

  1. Set up your web app for Capacitor (next lesson)
  2. Configure iOS development
  3. Configure Android development
  4. Add native features with plugins
  5. Deploy to app stores

Verify Your Understanding

You've completed this lesson if you can:

0/5

Next: Set up a Next.js project with Capacitor.