See how Capacitor fits into the entire Ionic Ecosystem ->
Capacitor is part of the Ionic Ecosystem ->

Svelte & Capacitor

Build native mobile apps with web technology and Svelte


Install Capacitor.

Add Capacitor to your project and create a config for your app

npm install @capacitor/core @capacitor/cli
npx cap init [name] [id] --webDir=public

Build the Web App.

The compiled web assets will be copied into each Capacitor native platform during the next step.

npm run build

Install the native platforms you want to target.


Capacitor's native projects exist in their own top-level folders and should be considered part of your app (check them into source control).

npx cap add android
npx cap add ios

Adding calls to Native APIs

With Capacitor installed, adding calls to native device features is as straight forward as calling other JavaScript methods

  import {Plugins} from '@capacitor/core';

  let loc = null;
  async function getCurrentPosition(){
    const { Geolocation } = Plugins;
    const res = await Geolocation.getCurrentPosition()
    loc = res

  <p>Your location is:</p>
  <p>Latitude: {loc?.coords.latitude}</p>
  <p>Longitude: {loc?.coords.longitude}</p>

  <button on:click={getCurrentPosition}>
    Get Current Location

Continue your Capacitor Journey.

This is only the beginning. Learn more about the Capacitor development workflow or using more native APIs .

The latest updates. Delivered monthly.

Capacitor is getting better every day. Sign up for a monthly email on the latest updates, releases, articles, and news!