Menu

1 / 2

Capacitor Has a Free API — Here's How to Build Native Mobile Apps with Web Tech

DEV Community: capacitor·Alex Spinov·5 months ago
#ujbWMFdK
#dev#await#capacitor#enter#article
Reading 0:00
15s threshold

Capacitor by Ionic lets you build native iOS and Android apps using web technologies. It provides a bridge between your web app and native device APIs — camera, geolocation, filesystem, and more.

Getting Started

npm install @capacitor/core @capacitor/cli npx cap init my-app com.example.myapp npx cap add ios npx cap add android

Enter fullscreen mode

Exit fullscreen mode

Camera Plugin

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

const photo = await Camera . getPhoto ({ quality : 90 , allowEditing : true , resultType : CameraResultType . Uri , source : CameraSource . Camera });

console . log ( photo . webPath ); // Display in <img> tag

Enter fullscreen mode

Exit fullscreen mode

Geolocation

import { Geolocation } from " @capacitor/geolocation " ;

const position = await Geolocation . getCurrentPosition (); console . log ( `Lat: ${ position . coords . latitude } ` ); console . log ( `Lng: ${ position . coords .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.