Ionic Native and ionic serve


Native plugins, say Camera just as one example, cannot be used with ionic serve and that’s expected.

However that means that apps that rely on native plugins cannot be developed in the browser, something that takes away one of the main advantages of Ionic.

Some Cordova plugins at least support the browser platform for testing. E.g. the mentioned Camera plugin provides a CameraProxy.js that uses the getUserMedia browser API to capture a picture.

Now it is possible to run in the Cordova “browser” platform (as opposed to ionic serve where Cordova is just not defined) with ionic platform add browser and ionic run browser. But there’s no real advantage of doing that compared to running on Android or iOS, it’s still not the same for livereload etc. as ionic serve.

What’s the best approach here? Maybe Ionic Native should add browser fallback wherever possible?

The alternative is to write a new project for each functionality (like Camera), wrapping the native plugin and adding fallback browser support when Cordova is not available. That’s kind of what Ionic Storage does after all.

But this would just duplicate the “browser” support already provided by Cordova plugins. Seems like there should be a more general approach to this problem. Thoughts?


The best way to deal with this it to use the livereload functionality. First you have to install the plugins that you need to use, so that they can get compiled in the binary. Then run ionic run android -l. Now the app will run on your phone, and will update every time you update the app on your computer.

There is currently a bug (not sure if it’s still there) where the app doesn’t get updated when you update your content. So you will have to run npm run watch in another terminal while the livereload server is running.

Livereload is basically just like ionic serve except that you will be running on a device/simulator instead of running on your browser.

I hope that helped.


That’s what I thought, but even without the current issue, in fact with Ionic 1 as well, I find that livereload with an emulator doesn’t always work reliably for me.

ionic serve is a lot more convenient. That’s why I think it would be nice to be able to use Cordova plugins in the browser.


Well some plugins have browser capabilities. But they still wouldn’t work with ionic serve. You will need to do something like:

ionic platform add browser
ionic run browser (not sure if -l flag works here)

The ionic serve command basically runs your app as if it’s a website.


Alright thanks. Just wanted to check if there were any plans to make Ionic Native work with ionic serve, before spending time writing my own wrappers.


If anything, we’re really keen on making the browser platform be a first class citizen in ionic/cordova land.

As it stands, the browser platform has been used for testing. But we’d like to expand it more into a proper PWA structure.


That makes sense, given that many plugins already support the browser platform. Rewriting the same sort of fallback implementations just for ionic serve seems like a waste of effort.


At the moment i run ionic run browser -l but it does not update even when i run npm run watch in a different tab