skills/ionic-react/SKILL.md
Guides the agent through Ionic Framework development with React — project structure, React-specific Ionic components, IonReactRouter and navigation patterns, Ionic lifecycle hooks (useIonViewWillEnter, useIonViewDidEnter, useIonViewWillLeave, useIonViewDidLeave), state management integration, and React-specific best practices for Ionic apps. Do not use for plain Capacitor React apps without Ionic (use capacitor-react), Ionic with Angular or Vue, creating a new Ionic app (use ionic-app-creation), upgrading Ionic to a newer version (use ionic-app-upgrades), or general Ionic component usage without React-specific context (use ionic-app-development).
npx skillsauth add capawesome-team/skills ionic-reactInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Develop Ionic Framework apps with React — project structure, IonReactRouter, React-specific components, lifecycle hooks, state management, and best practices.
@ionic/react.package.json dependencies (@ionic/react, @ionic/react-router, react, @capacitor/core), platforms (android/, ios/), build tools, and TypeScript usage. Only ask the user when something cannot be detected.Auto-detect the following by reading project files:
@ionic/react version from package.json.react version from package.json.@capacitor/core version from package.json (if present).tsconfig.json exists and if .tsx files are used.@ionic/react-router and react-router-dom are in package.json.package.json for redux, @reduxjs/toolkit, zustand, jotai, @tanstack/react-query, or similar.android/, ios/).vite.config.ts, angular.json, webpack.config.js, etc.A standard Ionic React project follows this structure:
project-root/
├── android/ # Android native project (Capacitor)
├── ios/ # iOS native project (Capacitor)
├── public/
├── src/
│ ├── components/ # Reusable UI components
│ ├── hooks/ # Custom React hooks
│ ├── pages/ # Page components (one per route)
│ ├── services/ # Service modules for API and native calls
│ ├── context/ # React context providers
│ ├── theme/
│ │ └── variables.css # Ionic CSS custom properties
│ ├── App.tsx # Root component with IonReactRouter
│ └── main.tsx # Entry point with setupIonicReact()
├── capacitor.config.ts # Capacitor configuration
├── ionic.config.json # Ionic CLI configuration
├── package.json
├── tsconfig.json
└── vite.config.ts # Or other bundler config
If the project does not follow this structure, adapt all guidance to the project's actual directory layout. Do not restructure the project unless the user explicitly asks.
The entry point must call setupIonicReact() before rendering the app. This function initializes the Ionic Framework for React.
Verify that src/main.tsx (or src/index.tsx) contains:
import { setupIonicReact } from '@ionic/react';
setupIonicReact();
setupIonicReact() accepts an optional configuration object for global settings:
setupIonicReact({
mode: 'ios', // Force iOS mode on all platforms ('ios' | 'md')
rippleEffect: false, // Disable Material Design ripple effect
animated: true, // Enable/disable all animations
});
If setupIonicReact() is missing or called after rendering, Ionic components will not function correctly.
Read references/routing.md for complete routing patterns including:
IonReactRouter setupIonRouterOutlet page managementIonTabsIonMenuuseIonRouterKey principles:
IonReactRouter instead of React Router's BrowserRouter. It is required for Ionic page transitions.IonRouterOutlet to contain routes. It manages the page stack and transition animations.component prop to Route — do not use render or children inside IonRouterOutlet.useIonRouter for programmatic navigation — it provides Ionic-aware navigation with transition animations.Read references/lifecycle.md for detailed lifecycle hook usage.
Ionic React pages stay mounted in the DOM after navigation. Standard React useEffect only fires on initial mount, not on every page visit. Use Ionic lifecycle hooks for per-visit logic:
| Hook | Use for |
| ----------------------- | ------------------------------------------------------ |
| useIonViewWillEnter | Refresh data before the page becomes visible |
| useIonViewDidEnter | Start animations or focus inputs after page is visible |
| useIonViewWillLeave | Pause media, save draft state |
| useIonViewDidLeave | Cleanup after page is fully hidden |
These hooks only work in components that:
component of a Route inside IonRouterOutlet.IonPage as their root element.Read references/hooks.md for all available hooks and usage examples.
Ionic React provides hooks for presenting overlays and controlling navigation without managing state manually:
| Hook | Purpose |
| ------------------- | ------------------------------------ |
| useIonAlert | Present alert dialogs |
| useIonToast | Show toast notifications |
| useIonActionSheet | Present action sheets |
| useIonLoading | Show/dismiss loading indicators |
| useIonModal | Present modals programmatically |
| useIonPopover | Present popovers programmatically |
| useIonPicker | Present picker dialogs |
| useIonRouter | Navigate with Ionic animations |
Read references/components.md for detailed component patterns including:
IonPageisOpen bindingIonRefresherIonInfiniteScrollKey principles:
IonPage as root. This is required for transitions and lifecycle hooks.onIonInput for text inputs and onIonChange for select, toggle, checkbox, and range components.e.detail.value (or e.detail.checked for toggles/checkboxes).isOpen for simpler state management, or use overlay hooks (useIonModal, useIonAlert, etc.) for imperative usage.Read references/state-management.md for patterns with React Context, Redux Toolkit, Zustand, and TanStack Query.
Key principles:
useIonViewWillEnter to refresh stale data.IonReactRouter. Context providers, Redux Provider, and QueryClientProvider should wrap the router so all pages have access.useState/useReducer are sufficient.After implementing changes:
npm run build
npx cap sync
npx cap run android
npx cap run ios
For development with live reload:
ionic serve
For native development with live reload:
ionic cap run android --livereload --external
ionic cap run ios --livereload --external
IonPage as its root element and is the component of a Route inside IonRouterOutlet. Lifecycle hooks do not fire in child components or components rendered via render/children props.IonReactRouter is used instead of BrowserRouter. Ensure routes use the component prop, not render or children. Verify IonRouterOutlet is a direct child of IonReactRouter or IonTabs.useIonViewWillEnter to refresh data on every page visit instead of useEffect with [].IonRouterOutlet within IonTabs. Do not nest a separate IonRouterOutlet inside a tab page.setupIonicReact errors or components not rendering: Ensure setupIonicReact() is called before ReactDOM.createRoot() or ReactDOM.render() in the entry file. Ensure all Ionic CSS files are imported (see Ionic CSS imports in src/App.tsx or src/main.tsx).IonBackButton not appearing: IonBackButton only renders when there is navigation history. Set the defaultHref prop to provide a fallback route when the page is accessed directly.onIonInput for IonInput/IonTextarea (not onChange). Use onIonChange for IonSelect, IonToggle, IonCheckbox, IonRange. Access values via e.detail.value.IonContent. For modals, include IonHeader with IonToolbar if a toolbar is needed.useIonRouter returns undefined: The hook must be used inside a component that is a descendant of IonReactRouter. Verify the component tree includes IonReactRouter as an ancestor.src/App.tsx or src/main.tsx. The theme variables.css file must be imported after the core Ionic CSS.ionic-app-development — General Ionic development covering components, theming, and CLI usage.ionic-app-creation — Create a new Ionic app from scratch.capacitor-react — Capacitor-specific React patterns for accessing native device features (without Ionic Framework).ionic-app-upgrades — Upgrade Ionic Framework to a newer version.capacitor-plugins — Install, configure, and use Capacitor plugins from official and community sources.tools
Guides the agent through migrating Capacitor apps from discontinued Ionic Enterprise SDK plugins (Auth Connect, Identity Vault, Secure Storage) to their Capawesome alternatives (OAuth, Vault, Biometrics, Secure Preferences, SQLite). Covers dependency detection, side-by-side API mapping, code replacement, and platform-specific configuration for each plugin pair. Do not use for migrating Capacitor apps or plugins to a newer version, setting up Capawesome Cloud, or non-Capacitor mobile frameworks.
tools
Guides the agent through installing, configuring, and using Capacitor plugins from six sources — official Capacitor plugins, Capawesome plugins, Capacitor Community plugins, Capacitor Firebase plugins, Capacitor MLKit plugins, and RevenueCat plugins. Covers installation, platform-specific configuration (Android and iOS), and basic usage examples. Do not use for migrating Capacitor apps or plugins to a newer version, setting up Capacitor Live Updates, or non-Capacitor mobile frameworks.
tools
Guides the agent through Ionic Vue development patterns — project structure, Vue-specific Ionic components (IonPage, IonRouterOutlet, IonTabs), navigation with Vue Router and useIonRouter, Ionic lifecycle hooks (onIonViewWillEnter, onIonViewDidEnter, onIonViewWillLeave, onIonViewDidLeave), composable utilities (useIonRouter, useBackButton, useKeyboard), tab-based routing, lazy loading, platform detection with isPlatform, and troubleshooting common Vue-specific issues. Do not use for general Ionic component theming or CLI usage (use ionic-app-development), creating a new Ionic app (use ionic-app-creation), Capacitor-specific Vue patterns without Ionic (use capacitor-vue), upgrading Ionic versions (use ionic-app-upgrades), or non-Vue frameworks like Angular or React.
tools
A comprehensive starting point for AI agents to work with the Ionic Framework. Covers core concepts, components, CLI, theming, layout, lifecycle, navigation, and framework-specific patterns for Angular, React, and Vue. Pair with the other Ionic skills in this collection for deeper topic-specific guidance like app creation, framework integration, and upgrades.