Capacitor

为 iOS、Android 和 Web 构建跨平台的原生渐进式 Web 应用。「Build cross-platform Native Progressive Web Apps for iOS, Android, and the Web ⚡️」

Github星跟踪图

Capacitor

使用 JavaScript 和 Web 的跨平台应用程序。

Capacitor 是一个跨平台的 API 和代码执行层,可以轻松地从 Web 代码中调用 Native SDK,并编写您的应用可能需要的自定义本地插件。此外,Capacitor 还提供了一流的 Progressive Web App 支持,因此您可以编写一个应用,并将其部署到应用商店和移动网络上。

Capacitor 自带 Plugin API,用于构建本地插件。插件可以在 Capacitor 应用内部编写,也可以打包成 npm 依赖程序供社区使用。我们鼓励插件作者在 iOS 中使用 Swift 开发插件,在 Android中 使用 Kotlin(或 Java)开发插件。

Capacitor 3.0 开发已经开始!

有兴趣关注《Capacitor 3》的开发吗?我们希望得到您的反馈! 以《Capacitor 3》策划刊为起点。如果您有问题或建议,请 展开讨论

我们很乐意听到您的意见。

入门

Capacitor 被设计成可以插入到任何现有的现代网络应用中。运行以下命令在您的应用程序中初始化 Capacitor。

npm install @capacitor/core @capacitor/cli
npx cap init

接下来,安装任何一个需要的本地平台:

npm install @capacitor/android
npx cap add android
npm install @capacitor/ios
npx cap add ios

新的应用程序?

对于新的应用程序,我们建议尝试使用 Ionic Framework 与 Capacitor。

首先,安装 Ionic CLI (npm install -g @ionic/cli) 并启动一个新的应用程序。

ionic start --capacitor

常见问题

Capacitor 和 Cordova 的区别是什么?

在精神上,Capacitor 和 Cordova 非常相似。Capacitor 提供了与绝大多数 Cordova 插件的向后兼容性。

Capacitor 和 Cordova 的不同之处在于,Capacitor:

  • 采用更现代的工具和插件开发方法。
  • 将本地项目作为源码工件来处理,而不是构建工件。
  • 是由 Ionic 团队维护的。

更多详情请看 文档

我需要将 Ionic Framework 与 Capacitor 一起使用吗?

不,您不需要在 Capacitor 上使用 Ionic Framework。如果没有 Ionic Framework,您可能需要自己实现 Native UI。如果没有 Ionic CLI,您可能需要自己配置工具来启用诸如 livereload 等功能。更多细节请参见 文档

贡献

参见 CONTRIBUTING.md.

贡献者

由 Capacitor 社区提供。


主要指标

概览
名称与所有者ionic-team/capacitor
主编程语言TypeScript
编程语言JavaScript (语言数: 8)
平台Android, Cross-platform, iOS, Electron
许可证MIT License
所有者活动
创建于2017-11-18 21:38:09
推送于2025-05-06 12:13:05
最后一次提交
发布数333
最新版本名称7.2.0 (发布于 2025-03-31 16:54:47)
第一版名称0.0.1 (发布于 )
用户参与
星数13.2k
关注者数169
派生数1.1k
提交数4.4k
已启用问题?
问题数3681
打开的问题数173
拉请求数2394
打开的拉请求数49
关闭的拉请求数454
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?

Build Status

⚡️ Cross-platform apps with JavaScript and the Web ⚡️

Capacitor is a cross-platform API and code execution layer that makes it easy to call Native SDKs from web code and to write custom Native plugins that your app might need. Additionally, Capacitor provides first-class Progressive Web App support so you can write one app and deploy it to the app stores, and the mobile web.

Capacitor was created by the Ionic Framework team as a spiritual successor to Cordova, though it does have backward compatibility with the majority of Cordova plugins. Capacitor can be used without Ionic Framework, but since it's a core part of the Ionic Platform, it's recommended for the best app development experience.

Capacitor also comes with a Plugin API for building native plugins. On iOS, first-class Swift support is available, and much of the iOS Capacitor runtime is written in Swift. Plugins may also be written in Objective-C. On Android, writing plugins in Java and Kotlin is supported.

Roadmap

Disclaimer: Our roadmap is subject to change at any time and has no specific date guarantees

2020 and beyond: The core Capacitor project is now stable. Maintenance is ongoing (including support for new mobile operating system versions, bugs, etc.). Going forward, most new functionality will be implemented as plugins. For the latest updates, track new releases here or milestones here.

2019

2018

  • Cordova Plugin Integration
    • Preliminary support for using plugins from the existing Cordova community
  • Electron support
    • Support for building Electron apps and interacting with Node.js libraries
  • Enterprise Premium Plugins
    • Paid add-on plugins with support for common Enterprise use cases, such as storage, authentication, security, and more
    • Developer Support options with SLAs and priority patches
    • We are working with a few large teams/businesses as early development partners. Interested? Email max@ionicframework.com

Contributing

Contributing to Capacitor may involve writing TypeScript, Swift/Objective-C, Java, or Markdown depending on the component you are working on. We are looking for help in any of these areas!

Please read the Contributing guide for more information.