capacitor

Capacitor cross-platform native runtime. Use for web to native.

7 stars

Best use case

capacitor is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Capacitor cross-platform native runtime. Use for web to native.

Teams using capacitor should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/capacitor/SKILL.md --create-dirs "https://raw.githubusercontent.com/G1Joshi/Agent-Skills/main/skills/mobile/capacitor/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/capacitor/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How capacitor Compares

Feature / AgentcapacitorStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Capacitor cross-platform native runtime. Use for web to native.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# Capacitor

Capacitor by Ionic is a cross-platform native runtime that makes it easy to build web apps that run on iOS, Android, and the web as Progressive Web Apps (PWAs). It provides a bridge to native APIs.

## When to Use

- Converting existing React/Angular/Vue web apps to mobile apps.
- Need specific native functionality (Camera, Haptics, Push) in a web app.
- Building plugins that need to work across iOS, Android, and Web consistent APIs.

## Quick Start

```bash
npm install @capacitor/core @capacitor/cli
npx cap init MyMobileApp com.example.app
npm install @capacitor/android @capacitor/ios
npx cap add android
npx cap add ios
```

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

const printCurrentPosition = async () => {
  const coordinates = await Geolocation.getCurrentPosition();
  console.log("Current position:", coordinates);
};
```

## Core Concepts

### Native Bridge

Capacitor injects a native bridge into the WebView, allowing JavaScript to call Native Code (Java/Kotlin/Swift/Obj-C) asynchronously.

### Plugins

Modular blocks of code that provide interface to native functionality.

- **Official Plugins**: Maintained by Ionic team (Camera, Filesystem).
- **Community Plugins**: Maintained by the community.

### Native Project Management

Capacitor treats native projects (`android/`, `ios/`) as "source artifacts", meaning you commit them to git and use native tooling (Android Studio/Xcode) to build and configure them (permissions, icons).

## Common Patterns

### Secure Storage

Use `@capacitor-community/http` for secure requests (bypassing CORS) and secure storage plugins for tokens (Keychain/Keystore) instead of `localStorage`.

### Deep Linking

Handle custom URL schemes (`myapp://`) for authentication redirects or opening specific content.

## Best Practices

**Do**:

- Use **official plugins** whenever possible for long-term maintenance.
- Sync your project frequently: `npx cap sync`.
- Handle **Permissions** gracefully in your UI before calling native APIs.
- Use **Live Reload** during development: `npx cap run android -l --external`.

**Don't**:

- Don't store sensitive data (API Keys) in JS code; use environment variables or native config.
- Don't ignore platform differences; test on real iOS and Android devices.
- Don't rely on `alert()`/`confirm()`; use Capacitor Dialog plugin or UI framework modals.

## Troubleshooting

| Error                                  | Cause                                       | Solution                                                      |
| :------------------------------------- | :------------------------------------------ | :------------------------------------------------------------ |
| `Plugin not implemented`               | Plugin not installed or platform not added. | Run `npx cap sync` and check imports.                         |
| `Cleartext HTTP traffic not permitted` | Android security preventing http requests.  | Use HTTPS or update `network_security_config.xml` (dev only). |
| `Xcode build failed`                   | Pods out of sync or signing issue.          | `npx cap update ios` then check Signing in Xcode.             |

## References

- [Capacitor Documentation](https://capacitorjs.com/docs)
- [Capacitor Plugins](https://capacitorjs.com/docs/apis)