Capacitor Whitepaper
Capacitor Whitepaper
Capacitor Whitepaper
Building
cross-platform
apps with
Capacitor
Whitepaper
contents
introduction
The Ionic team created Capacitor as a Cordova was capable of. That’s due in no
spiritual successor to Apache Cordova and small part to the fact that many of the new,
Adobe PhoneGap, with inspiration from modern APIs were not available previously.
other popular cross-platform tools like
Eventually, we reached a fork in the road,
React Native and Turbolinks, but focused
and decided it would be better to forge our
entirely on enabling modern web apps to
own path, rather than iterate on top of what
run on all major platforms with ease.
Cordova had already built. It was a tough
decision; but looking back, I have no doubt
that it was the right one.
For example, Capacitor embraces npm to manage plugins, Swift for iOS, Java for Android,
TypeScript, and has full support for Progressive Web Apps. Capacitor makes it possible
to build one app for iOS, Android, and the Web, all with one code base. Capacitor has
first-class support for building plugins; in fact the plugin authoring experience has been
a focus from the very beginning. Capacitor treats native projects as source-artifacts,
meaning native code can quickly be added without worrying about changes being lost.
Capacitor does away with device-ready or async plugin loading, a common source of
confusion and bugs with Cordova developers, so all plugins are available as soon as the
page starts loading. And that’s just the tip of the iceberg.
Today, Capacitor is the most cost effective path to deploying a single app to multiple
platforms.
Don’t just ask us! Since its launch, Capacitor has grown to more than 500K monthly
installs and is poised to eclipse Cordova as the #1 native runtime for hybrid apps. In other
words, developers really like Capacitor. We’re thrilled to report some notable companies
using Capacitor include Tim Horton’s, Popeye’s, and Sworkit, to name a few.
Building on the initial success of Capacitor, Ionic released Capacitor 2.0 in April 2020,
then followed up with version 3.0 in May 2021.
With the release of Capacitor 3.0, we planted a stake in the ground: Capacitor is now the
standard for web developers building mobile apps. We’re firmly committed to making
mobile development just as good as web development, and that’s exactly what Capacitor
enables. Whether you have an existing web project or are curious about starting a new
mobile project, we hope you’ll check out Capacitor.
The emergence
of cross-platform
development
Today, about 60% of all apps in the app store are cross-platform. This means apps that
run on iOS and Android from a shared codebase, using cross-platform solutions like React
Native, Ionic, and Cordova. And increasingly, Capacitor.
Given the thousands of apps released in the app stores each year, and the prodigious
appetite for mobile inside many businesses, cross-platform development approaches
have emerged as a way to meet the demand for mobile applications, by speeding up and
simplifying how development gets done. They do this in a few ways.
First, instead of writing separate code for each platform, cross-platform solutions allow
you to share code across platforms. You write your code once and it works seamlessly
across iOS and Android. That benefit alone can lead to time savings of 50% or more.
Secondly, by abstracting much of the native complexity, these solutions have made it so
that just about anyone with a basic knowledge of JavaScript, HTML, and CSS can now
build a high-quality mobile app.
Building cross-
platform apps
with the web
Within the cross-platform category, there are two main
categories of solutions.
So-called “cross-platform native” solutions like React Native and Xamarin are tightly
coupled with the native mobile platforms. Written and controlled largely in JavaScript or
C#, they boast solid performance and allow developers to build mobile experiences with
native UI controls.
In contrast, Cordova and Capacitor are primarily web-based in nature — often referred to
as “hybrid” solutions, in reference to the fact that they combine native runtime features
with a web UI layer. Although hybrid apps run natively on the device and interact with any
available native APIs, the UI layer of the app is executed primarily in a web browser, known
as a WebView, that is invisible to the user.
• If you’re already familiar with the traditional web languages and approaches, you’ll be
right at home. There are no additional languages to learn.
• If you have an existing web project that you want to bring to mobile, you can do that
using a native runtime like Cordova or Capacitor.
• If you have a web UI library that you’d like to use in mobile - whether it’s a corporate
design system or a packaged UI library like Bootstrap - you can bring those UI
components to mobile using a hybrid approach.
• If you’re building an app that you’d like to deploy across mobile and web, including
PWAs, then a hybrid approach makes sense.
On top of that, because the UI of a hybrid application runs entirely in the browser, it’s
possible to target iOS, Android, desktop and the web, all from a single shared codebase.
That’s in contrast to cross-platform native solutions that often require separate native
code on each platform, along with a third “control” layer for any shared code across
platforms.
Of course, some will debate whether running the UI in a browser adds a big performance
hit, but the truth is that advances in native devices, browser technologies, and runtimes
like Capacitor have rendered these issues largely obsolete. For proof, just download one
of the many successful hybrid apps on the market, including Shipt, Sworkit, Sanvello — all
highly rated consumer apps serving millions of users.
Capacitor: A new
approach to cross-
platform development
Capacitor is an open source project that runs modern Web Apps
natively on iOS, Android, Electron, and Web, while providing a
powerful and easy-to-use interface for accessing Native SDKs
and Native APIs on each platform.
Also, building plugins that offer web functionality as a fallback simply requires adding
a few files to your plugin. Capacitor will only use your web implementation if the native
one is not available, so users can use the exact same API when running on iOS, Android,
Electron, and the web. Here is the Capacitor Camera API, for example. Notice there is no
platform-specific code:
CLI tooling that is version managed per app Capacitor takes a “web first” approach
Capacitor provides a small CLI tool that is We believe that the core of every great cross-
installed locally to each app. That means there platform hybrid app is a quality, modern
are no global dependencies to manage and it’s Progressive Web App (PWA). This keeps your app
easy to use different versions of Capacitor across aligned with the rapidly evolving web platform
every app you build. This is a boon to teams while enabling powerful native device functionality
that are building multiple apps with potentially on platforms that support it. Capacitor has
differing dependency versions or version even convinced native developers or users of
management processes. alternative platforms that see the benefits of web
development on mobile, and customer feedback
Native and web developer collaboration indicates that Capacitor is finally providing the
Since Capacitor apps are actual native apps development experience they prefer.
and a key design consideration of Capacitor is
embracing native tooling, Capacitor enables Easily access native device features
teams that have both traditional native mobile Developers have access to the full Native SDK
and web developers to collaborate on mobile app on each platform, and can easily deploy to App
projects. Traditional native mobile developers Stores, and the web. Adding native functionality is
can use their programming languages of choice easy with a simple Plugin API for Swift on iOS, Java
(Swift/Objective-C on iOS, Java/Kotlin on on Android, and JavaScript for the web.
Android) to build UI experiences or business
Capacitor apps access native and web features
logic and then expose them to the Web layer
using a series of platform APIs (AKA plugins). While
through Capacitor’s JavaScript-to-native APIs.
the base Capacitor experience includes a series of
This also ensures an app team never gets stuck
core plugins, along with OSS contributed plugins,
implementing the functionality it needs.
you can easily add your own custom device
Cordova, in contrast, works through an functionality by writing a plugin of your own.
abstraction layer that manages the underlying
Using Capacitor, developers can build one app
native platform project and source files for
and target a single set of APIs regardless of the
you, making it harder to drop down to native
platform the app is running on, as opposed to
code or work with a traditional native mobile
managing multiple APIs for each target platform.
development process, and can result in custom
As illustrated in the example above, accessing the
changes being lost.
Camera uses the same code on iOS/Android as it
does on Electron and on the web.
Building a native mobile app on iOS and Building a Progressive Web App
Android Capacitor has first-class support for Progressive
Capacitor makes it easy to build and deploy Web Apps (PWAs) and native apps. That means
native mobile apps for iOS and Android, using that Capacitor’s plugin bridge supports running
familiar web languages, libraries, and frameworks, in either a native context or on the web, with
without the underlying complexity of the native many core plugins available in both contexts with
SDKs and iOS and Android specific code. Mobile the exact same API and calling conventions. This
applications built with Capacitor are optimized means you’ll use @capacitor/core as a dependency
for native performance and have full access to for both your native app and your Progressive Web
any native device features, including full access App, and Capacitor will seamlessly call web code
to the native SDKs when needed. The UI layer when required and native code when available.
of any Capacitor mobile app primarily runs in
Capacitor also offers a number of utilities
the browser, so that any new or existing web
for querying the current platform to provide
applications can be deployed as a native mobile
customized experiences when running natively or
application.
on the web.
It also means any popular UI framework like Bootstrap, Material, or Tailwind will work great
in Capacitor. While you’ll need to anticipate and address the many mobile-specific UI
paradigms (see below), your existing web-based library will now run natively on any iOS or
Android device, and on the web as a PWA.
As an alternative to rolling your own solution from scratch, you can use a mobile-ready
UI library like Ionic Framework instead. You can then incrementally add your own custom
components as needed. Or, start with your UI library as the foundation, and incrementally
add Framework components as you need them. There are a variety of options, and it’s not
an all-or-nothing proposition.
Using Capacitor
in an enterprise
environment
Capacitor is truly unique as an open source project in that it has a real company behind
it. That company, Ionic, is in the business of enterprise app development. That means our
sole focus is to provide teams building mission-critical apps the support and enterprise-
specific functionality they need to be successful. Ionic, the team behind Capacitor,
works with hundreds of enterprise customers, building everything from major consumer
transportation apps, fast-food retail apps, internal B2E apps, and a whole lot more.
Ionic offers dedicated support across Capacitor and its native APIs, as well as advanced
enterprise native features like secure token management, encrypted offline storage, and
OpenID Connect-powered single sign-on. Additionally, teams can build best-of-breed user
experiences on top of Capacitor using the highly popular Ionic Framework.
Capacitor is a key aspect of Ionic’s mobile infrastructure and the infrastructure of its
customers. That means security and functionality issues are discovered, fixed, and
released quickly. Capacitor has a full-time team of engineers, product management,
marketing, and customer success experts dedicated to customer and project success.
Migrating to Capacitor
from Cordova
If your team is currently using Cordova and curious about moving
to Capacitor, then you will welcome the fact that Capacitor
has backward-compatible support for a large swath of existing
Cordova plugins. Migrating to Capacitor from Cordova is well-
documented and uncomplicated.
Adopting Capacitor
Capacitor is a key aspect of Ionic’s mobile infrastructure and the
infrastructure of its customers. To date, Capacitor is installed
over 6 million times a year, and is currently powering major
production enterprise apps with hundreds of millions of users.
Suffice to say, Capacitor is now a major force in the mobile
development ecosystem and is a major element of Ionic’s
enterprise business. Even native developers (or alternative
platforms) are recognizing the benefits of web development
on mobile, and are satisfied with the development experience
Capacitor provides.
— Rakesh Gadapa, Application Developer III at Blue Cross Blue Shield of Michigan.
Book a strategy
session with a
Solutions Engineer
today.
15 For more Ionic white papers, visit: ionicframework.com/resources