capacitor README

The project's README from github.com/ionic-team/capacitor. As one markdown file: README.md.


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


Capacitor lets you run web apps natively on iOS, Android, Web, and more with a single codebase and cross-platform APIs.

Capacitor provides 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 may 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 comes with a Plugin API for building native plugins. Plugins can be written inside Capacitor apps or packaged into an npm dependency for community use. Plugin authors are encouraged to use Swift to develop plugins in iOS and Kotlin (or Java) in Android.

Getting Started

Capacitor was designed to drop-in to any existing modern web app. Run the following commands to initialize Capacitor in your app:

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

Next, install any of the desired native platforms:

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

New App?

For new apps, we recommend trying the Ionic Framework with Capacitor.

To begin, install the Ionic CLI (npm install -g @ionic/cli) and start a new app:

ionic start --capacitor

FAQ

What are the differences between Capacitor and Cordova?

In spirit, Capacitor and Cordova are very similar. Capacitor offers backward compatibility with a vast majority of Cordova plugins.

Capacitor and Cordova differ in that Capacitor:

See the docs for more details.

Do I need to use Ionic Framework with Capacitor?

No, you do not need to use Ionic Framework with Capacitor. Without the Ionic Framework, you may need to implement Native UI yourself. Without the Ionic CLI, you may need to configure tooling yourself to enable features such as livereload. See the docs for more details.

Contributing

See CONTRIBUTING.md.

Contributors

Made possible by the Capacitor community. 💖

capacitor (ionic-team/capacitor)

Searching Database…

16.9K ·GitHub
这是什么?Capacitor 是一个跨平台运行时,让你用同一套代码把 Web 应用以原生方式运行在 iOS、Android 和网页上,并提供 API 让 JavaScript 调用原生 SDK。
它是框架还是添加到我项目里的库?它是一个可以直接放进 Web 应用的跨平台 API 和代码执行层:它把你的 JavaScript 桥接到原生 SDK,还支持你编写自定义原生插件。
怎么把它加到现有的 Web 应用里?它专为接入任何现有现代 Web 应用而设计:在项目里运行 init 命令,然后安装你需要的原生平台即可。对于全新应用,README 建议从 Ionic 入手,用 npm install -g @ionic/cli 安装。
使用它需要 Ionic Framework 吗?不需要。不用 Ionic 的话,你可能需要自己实现原生 UI,并手动配置 livereload 之类的工具,但 Capacitor 单独使用完全没问题。
我以前用过 Cordova,我的应用和插件能直接迁移过来吗?两者的思路非常接近,而且 Capacitor 向后兼容绝大多数 Cordova 插件。区别只是它采用了更现代的工具链,并把原生项目当作源码产物而不是构建产物来管理。
同一套代码也能跑到普通网页上吗?可以,Capacitor 对渐进式 Web 应用(PWA)有一流的支持,同一个应用既能上架应用商店,也能发布到移动端网页。
编写自己的原生插件该用什么语言?官方建议插件作者在 iOS 上使用 Swift,在 Android 上使用 Kotlin(或 Java)。
我可以把我的插件分享给其他开发者吗?可以,插件既可以放在你的 Capacitor 应用内部,也可以打包成 npm 依赖供社区使用。
Capacitor 是免费开源的吗?是的,它采用 MIT 许可证,由 Ionic Team 维护,也就是 Ionic Framework 背后的同一个团队。
Creator
ionic-team
Size
74.6 MB
Stars
16.9K
Age
8y
Commits · 90 Days