Use capacitor api/plugins for electron & android without ionic? #3226
-
I want to develop an app with capacitor without using ionic. How can I use the capacitor plugins this way? I added the electron and android build targets. If I include a script
I had to: which produces the error: **Uncaught TypeError:
What should the path be or is there some other script that can run concurrently and interact with the dom thread like electron and still be compatible with android/ios? I must be doing something wrong. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
We're still in the process of building more examples - but I think this thread could help. |
Beta Was this translation helpful? Give feedback.
-
To use the import syntax to external packages that you installed through npm (such as If you don't want to use a bundler, you can set the Then You can use it like
or
|
Beta Was this translation helpful? Give feedback.
To use the import syntax to external packages that you installed through npm (such as
@capacitor/core
) you'll need to use a bundler such as webpack, snowflake, babel, rollup, etc.If you don't want to use a bundler, you can set the
bundledWebRuntime
option incapacitor.config.json
file totrue
.That will copy a
capacitor.js
file into the www folder with all@capacitor/core
code and you can link it in your index.html like<script type="text/javascript" src="capacitor.js"></script>
.Then
Capacitor
object becomes available and you can just use it.You can use it like
Capacitor.Plugins.Device.getInfo().then(info => console.log(info));
or