Skip to main content
Version: v8 (beta)

Capacitor Plugins

Getting started with Capacitor is fairly straight forward for Ionic developers. Adding plugins to your project is no different than adding any dependencies you may need to a project.

Install

To install a plugin, find the plugin you want to use and install it using your package manager, like npm:

# Install the Capacitor Plugins
$ npm install @capacitor/camera

Usage

Once installed, plugins can be imported into a component and you can call the native functionality directly from your code.

Using the Camera plugin as an example, first install it:

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

const takePicture = async () => {
const image = await Camera.getPhoto({
quality: 90,
allowEditing: true,
resultType: CameraResultType.Uri
});
const imageUrl = image.webPath;
imageElement.src = imageUrl;
};