Updating Capacitor to 3.0 in your app
Capacitor 3 brings crucial updates to the ecosystem and exciting new features.
Read the Capacitor 3.0 announcement ›
After upgrading your app to Capacitor 3, would you mind sharing any feedback you have in this discussion? We'd love to hear from you! 💖
If you're a plugin author looking to upgrade your plugins to newer Capacitor versions, see the Upgrade Guide for Capacitor Plugins.
NodeJS 12+
Node 8 has reached end-of-life. Node 10 will reach end-of-life on April 30th, 2021. Capacitor 3 requires NodeJS 12 or greater. (Latest LTS version is recommended.)
Ionic CLI
If you are using the Ionic CLI, official Capacitor 3 support starts at version 6.16.0. We suggest upgrading to the latest version at this time via npm install -g @ionic/cli
.
Update Capacitor CLI and Core
npm install @capacitor/cli@latest-3 @capacitor/core@latest-3
ES2017+
Capacitor 3 now builds for ES2017 environments, instead of ES5. The plugin template has also been updated to target ES2017, and third-party plugins are encouraged to update their targets.
This change should not affect your app unless you are supporting IE11, which Capacitor does not officially support.
TypeScript 3.8+
Capacitor 3 uses a newer TypeScript syntax which can only be used in TS 3.8 or later.
Capacitor Config changes
If you have TypeScript 3.8+ installed, you can migrate your capacitor.config.json
to be a typed TypeScript config file named capacitor.config.ts
. You can continue using a .json
file, but a typescript config file may give a better developer experience for your team. Below is an example capacitor.config.ts
file that is used in the Capacitor Test App.
/// <reference types="@capacitor/local-notifications" />
/// <reference types="@capacitor/push-notifications" />
/// <reference types="@capacitor/splash-screen" />
import { CapacitorConfig } from '@capacitor/cli';
const config: CapacitorConfig = {
appId: 'com.capacitorjs.app.testapp',
appName: 'capacitor-testapp',
webDir: 'build',
plugins: {
SplashScreen: {
launchAutoHide: false,
},
LocalNotifications: {
smallIcon: 'ic_stat_icon_config_sample',
iconColor: '#CE0B7C',
},
PushNotifications: {
presentationOptions: ['alert', 'sound'],
},
},
};
export default config;
Official Plugins
All plugins have been removed from Capacitor core and placed into their own npm packages. There are several reasons for this (see #3227) and the core team is confident this is the right way to go. You can import core plugins like so.
import { Camera } from '@capacitor/camera';
Background Task, Permissions, and Photos plugins removed
- Background Task: This plugin appeared to be rarely used and didn't quite work as most devs expected. The core team will readdress background functionality in the future. Subscribe to #3032 for updates.
- Permissions: The core team has implemented an alternative to this centralized approach which community plugins may also adopt (see the new Permissions API).
- Photos: This undocumented iOS-only plugin has been removed. Use
@capacitor-community/media
.