Skip to content
Discussion options

You must be logged in to vote

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 in capacitor.config.json file to true.
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

const { Plugins } = Capacitor;
Plugins.Device.getInfo()…

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
1 reply
@bitnom
Comment options

Comment options

You must be logged in to vote
3 replies
@bitnom
Comment options

@jcesarmobile
Comment options

@mbushpilot2b
Comment options

Answer selected by bitnom
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants