How to use plugins like Filesystem in VanillaJS

You need to install the plugins as explained on each plugin docs, then you can still use Capacitor.Plugins object, every plugin you install will be added to the object, but that will only work on iOS and Android native builds.

If you want to use plugins on web, I recommend using a bundler/loader.

If you don’t want to use a bundler/loader, you can use something simpler like pika web.

By running npx @pika/web --dest www, it searches for packages in your node_modules and copies them to the www folder. Then you can create a .js file and put it in your head like this <script src="script.js" type="module"></script>, and inside it you can do import { Camera } from './@capacitor/camera.js'; and use it as the plugin docs say.

Well, this still looks like a bundler/loader, but simpler.

2 Likes