capacitor-react

Guides Capacitor app development with React hooks, plugins, and platform patterns.

1|Updated Aug 25, 2026
One-click install
npx skills add https://github.com/involvex/ionic-everywhere --skill capacitor-react-involvex
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: capacitor-react
Source: https://github.com/involvex/ionic-everywhere/tree/main/.agents/skills/capacitor-react
Command: npx skills add https://github.com/involvex/ionic-everywhere --skill capacitor-react-involvex

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Building Capacitor apps with React requires bridging native device APIs and React's component model correctly — listeners leak without cleanup, native calls fail on web, and platform differences break builds. This Skill provides structured guidance for integrating Capacitor plugins into React components, hooks, and state management without common pitfalls. ## Core Features & Use Cases - Plugin Integration Patterns: Import and call Capacitor plugins in components with platform guards, permission checks, and loading/error state handling. - Custom Hooks for Native Features: Reusable hooks for network status, keyboard, geolocation, camera, preferences, and app lifecycle events with proper useEffect cleanup. - Navigation and Lifecycle: Deep link handling via appUrlOpen, Android back button handling, and platform-specific rendering with Capacitor.getPlatform(). - Use Case: Add a camera feature to a React Capacitor app — the Skill guides permission checks, photo capture with loading state, and cleanup so the feature works on iOS, Android, and degrades gracefully on web. ## Quick Start Help me add a Capacitor native feature, such as camera or geolocation, to my React app using a custom hook with proper listener cleanup.

Frequently Asked Questions about capacitor-react

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I use Capacitor plugins in React components?

Import Capacitor plugins as ES modules and call their methods inside event handlers or useEffect, never at module top level. Wrap native-only calls with Capacitor.isNativePlatform() so they do not fail on web.

How to handle Capacitor event listeners in React hooks?

Register listeners inside useEffect and return a cleanup function that calls remove() on the listener handle. This prevents duplicate listeners on re-renders and memory leaks, which React 18 strict mode double-mounting helps expose.

Does Capacitor work with React state management libraries?

Yes. Use React Query query functions that call Capacitor plugins for fetched native data, or dispatch Redux/Zustand actions from plugin callbacks. Keep native API calls in action creators or service modules, not in reducers.

Why does my Capacitor plugin fail at runtime in React?

Usually npx cap sync was not run after installing the plugin, or @capacitor/core is missing. Also verify the call is guarded for web, since some plugins like Camera with native UI only work on iOS and Android.

How do I handle the Android back button in a React Capacitor app?

Register a backButton listener from @capacitor/app inside a useEffect. Navigate back with your router's navigate(-1) when canGoBack is true, otherwise call App.exitApp(), and remove the listener on cleanup.

When should I not use this Capacitor React guidance?

Do not use it for Ionic Framework React apps, which need the ionic-react skill for IonReactRouter and lifecycle hooks, or for migrating Capacitor versions, which is covered by capacitor-app-upgrades.