Skip to content

How to understand a Ionic and Capacitor codebase

Capacitor wraps a web app in native iOS and Android shells and gives it plugins for device features. Ionic adds mobile UI components on top of Angular, React or Vue. The bulk of the code is a normal web app; the native layer is the plugins and shells.

How to tell it's Ionic and Capacitor

  • capacitor.config.ts and @capacitor/core in package.json
  • @ionic/angular, @ionic/react or @ionic/vue
  • android/ and ios/ folders

Where things usually live

capacitor.config.ts
App ID, web build folder (webDir), plugin settings.
src/
The web app, structured by its framework.
src/app/ or src/pages/
Ionic pages with ion-* components.
android/ and ios/
Native shells; synced with npx cap sync.

Conventions, not rules. Real projects rename and move things, so confirm against the repository.

Where to start reading

  1. The web framework's entry and router
  2. Calls to @capacitor/* plugins, which are the native touchpoints
  3. capacitor.config.ts

How a request moves through the code

  1. 1The native shell starts and loads the built web app from webDir.
  2. 2The web app runs as usual, with Ionic components styled for each platform.
  3. 3Device features are called through Capacitor plugins, which call native code.
  4. 4Results return to JavaScript as promises.

Questions to ask about the repository

  • Which Capacitor plugins are used, and where?
  • What platform-specific code exists in the native folders?
  • How does the app behave when run in a browser instead of on a device?

What trips people up

  • Changes to the web app need a build and cap sync before they appear in native builds.
  • Some plugins don't work in the browser, so check for platform guards.