Skip to content
Mobileintermediate

What is Capacitor?

Updated Nov 30, 20263 min readBased on official documentation
What is Capacitor?

In short

Capacitor is a open-source runtime from the Ionic team that lets you wrap a web app written with standard JavaScript tools and run it as a native app on iOS, Android and other platforms. It lets you use web code while still reaching native device features through a plugin API.

Capacitor is a tool for building mobile apps with web technology. You write your interface with HTML, CSS and JavaScript, and Capacitor packages that code so it runs inside a native app shell on each platform. The result is an app you can publish to the App Store and Google Play, without writing the whole user interface twice.

The idea is not new. Older hybrid tools also ran web code inside a native container. Capacitor is the next step in that approach. The documentation describes it as a way to build "Web Native" apps: web-first projects that still have full access to native SDKs when you need them.

How it works

Capacitor sits between your web code and the operating system. Your app runs in a web view, which is a built-in component that displays web pages inside a native screen. Capacitor adds a bridge between that web view and native code, so JavaScript can call device features such as the camera, storage or notifications.

The platform-specific parts live in native projects. For iOS, the native code is written in Swift. For Android, it is written in Java. For the web, plugins are plain JavaScript. A plugin gives you one JavaScript interface, and the matching native code runs behind it on each platform.

You can add Capacitor to an existing modern JavaScript project, or start a fresh project from scratch. In both cases, the usual web build step creates the files that Capacitor copies into the native projects.

When to use it

Capacitor fits teams that already know web development and want one codebase for web and mobile. If your app already works in a browser, it will often work in a mobile app with little change. The documentation puts it this way: if it works in the browser, it probably works in a mobile app when using Capacitor.

It is also a good fit when you want to keep web standards as your main target. Capacitor aims to keep your code close to those standards and to reach native features only where they are needed.

If you need a single app for a very different kind of interface, or you want the platform's own UI toolkit everywhere, a native-first approach or a framework such as Flutter may suit you better.

A simple example

The usual starting point is a web project with a build step. After you install Capacitor, you add the native platforms and then sync your built web files into them. The commands look like this:

npm install @capacitor/core @capacitor/cli
npx cap init
npm install @capacitor/android @capacitor/ios
npx cap add android
npx cap add ios
npm run build
npx cap sync
npx cap open android

The last command opens the Android project in Android Studio. Each time you change your web code, you build it and run the sync command again, so the native projects get the latest files.

To use a device feature, you install the matching plugin and call it from JavaScript. The plugin hides the native details, so your app code stays the same on each platform.

Common mistakes

The first mistake is forgetting to sync after a build. Native projects keep their own copy of your web files, so changes do not appear until you run the sync step again.

The second is assuming every browser feature works the same in a native app. The web view on each platform can differ in version and behavior, so test on real devices, not only in a desktop browser.

The third is adding native code too early. Start with the web layer and add plugins only for the features you really need. This keeps your app easier to maintain.

Alternatives

Capacitor is not the only option. Other hybrid tools use a similar web-in-native model. If your team prefers a different language, native development with Swift and Kotlin, or a cross-platform framework, you have other paths too. For web apps that install to the home screen without a store listing, a Progressive Web App may be enough. Pick the tool that matches your skills and the features your app needs.

The official documentation is the best place to continue. Follow the Installation guide there to set up your first app.

FAQ

Is Capacitor free to use?

Capacitor is an open-source project. Check its license and the official documentation for the current terms before you start a commercial project.

Do I need to know Swift or Java to use Capacitor?

Not always. Most of your app is written in JavaScript. You only need Swift or Java when you write a custom native plugin or change native project settings.

Can Capacitor add to an existing web project?

Yes. The documentation says Capacitor can be dropped into any existing modern JavaScript project, so you do not have to start over.

How is Capacitor different from a WebView alone?

A WebView only shows web pages. Capacitor adds a bridge and plugin API so your web code can also reach device features like the camera.

Sources

This page is based on the official documentation below. Read it for full detail.

Capacitor — official documentation ↗
blozhikDeveloper news from across the web, explained. Every story links to its original sources.