capacitor-angular
БесплатноБез исполняемых скриптовНе проверенGuides the agent through Angular-specific patterns for Capacitor app development. Covers project structure, adding Capacitor to Angular projects, using…
от capawesome-team★ 56 звёзд на GitHubОб этом скилле
Capacitor with Angular
Angular-specific patterns and best practices for Capacitor app development — project structure, services, lifecycle hooks, NgZone integration, and plugin usage.
Prerequisites
- Capacitor 6, 7, or 8 app with Angular 16+.
- Node.js and npm installed.
- Angular CLI installed (
npm install -g @angular/cli). - For iOS: Xcode installed.
- For Android: Android Studio installed.
Agent Behavior
- Auto-detect before asking. Check the project for
angular.json,package.json,capacitor.config.tsorcapacitor.config.json, and existing directory structure. Only ask the user when something cannot be detected. - Guide step-by-step. Walk the user through the process one step at a time.
- Adapt to project style. Detect whether the project uses standalone components or NgModule-based architecture and adapt code examples accordingly.
Procedures
Step 1: Analyze the Project
Auto-detect the following by reading project files:
- Angular version: Read
@angular/coreversion frompackage.json. - Capacitor version: Read
@capacitor/coreversion frompackage.json. If not present, Capacitor has not been added yet — proceed to Step 2. - Architecture style: Check
src/main.tsforbootstrapApplication(standalone) vs.platformBrowserDynamic().bootstrapModule(NgModule). Checkangular.jsonfor further confirmation. - Platforms: Check which directories exist (
android/,ios/). - Capacitor config format: Check for
capacitor.config.ts(TypeScript) orcapacitor.config.json(JSON). - Build output directory: Read
outputPathfromangular.jsonunderprojects > <project-name> > architect > build > options > outputPath. This is needed for Capacitor'swebDirsetting.
Step 2: Add Capacitor to an Angular Project
Skip if @capacitor/core is already in package.json.
Install Capacitor core and CLI:
npm install @capacitor/core npm install -D @capacitor/cliInitialize Capacitor:
npx cap initWhen prompted, set the web directory to the Angular build output path detected in Step 1. For Angular 17+ with the application builder, this is typically
dist/<project-name>/browser. For older Angular versions, it is typicallydist/<project-name>.Verify the
webDirvalue in the generatedcapacitor.config.tsorcapacitor.config.jsonmatches the Angular build output path. If incorrect, update it:capacitor.config.ts:import type { CapacitorConfig } from '@capacitor/cli'; const config: CapacitorConfig = { appId: 'com.example.app', appName: 'my-app', webDir: 'dist/my-app/browser', }; export default config;capacitor.config.json:{ "appId": "com.example.app", "appName": "my-app", "webDir": "dist/my-app/browser" }Build the Angular app and add platforms:
ng build npm install @capacitor/android @capacitor/ios npx cap add android npx cap add ios npx cap sync
Step 3: Project Structure
A Capacitor Angular project has this structure:
my-app/
├── android/ # Android native project
├── ios/ # iOS native project
├── src/
│ ├── app/
│ │ ├── app.component.ts
│ │ ├── app.config.ts # Standalone: app configuration
│ │ ├── app.module.ts # NgModule: root module
│ │ ├── app.routes.ts # Routing configuration
│ │ └── services/ # Angular services for Capacitor plugins
│ ├── environments/
│ │ ├── environment.ts
│ │ └── environment.prod.ts
│ ├── index.html
│ └── main.ts
├── angular.json
├── capacitor.config.ts # or capacitor.config.json
├── package.json
└── tsconfig.json
Key points:
- The
android/andios/directories contain native projects and should be committed to version control. - The
src/directory contains the Angular app, which is the web layer of the Capacitor app. - Capacitor plugins are called from Angular services or components inside
src/app/.
Step 4: Using Capacitor Plugins in Angular
Capacitor plugins are plain TypeScript APIs. Import and call them directly in Angular components or services.
Direct Usage in a Component
import { Component } from '@angular/core';
import { Geolocation } from '@capacitor/geolocation';
@Component({
selector: 'app-location',
template: `
<div>
<p>Latitude: {{ latitude }}</p>
<p>Longitude: {{ longitude }}</p>
<button (click)="getCurrentPosition()">Get Location</button>
</div>
`,
standalone: true,
})
export class LocationComponent {
latitude: number | null = null;
longitude: number | null = null;
async getCurrentPosition() {
const position = await Geolocation.getCurrentPosition();
this.latitude = position.coords.latitude;
this.longitude = position.coords.longitude;
}
}
Wrapping Plu
Установить capacitor-angular в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл capacitor-angular?
Guides the agent through Angular-specific patterns for Capacitor app development. Covers project structure, adding Capacitor to Angular projects, using Capacitor plugins in Angular services and components, NgZone integration for plugin event listeners, lifecycle hook patterns, dependency injection, routing with deep links, and environment-based platform detection. Do not use for creating a new Capacitor app from scratch, upgrading Capacitor versions, installing specific plugins, Ionic Framework setup, or non-Angular frameworks.
Как установить скилл capacitor-angular?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл capacitor-angular запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic