How can I use cordova plugins in the browser?

I’m trying to use @ionic-native/http/ngx in the browser using ionic serve --lab but I get an error message saying cordova is not available.

I am using Ionic 5 with Capacitor, what can I do? I want to keep using the Ionic lab server because I can see both versions at the same time.

You can’t. Cordova is not available via ionic serve. It is only available on real devices (and i think only on browser if you build you project for it via ionic cordova build browser)

You cannot use cordova plugins in the brower. The browser platform that @EinfachHans mentions is not really meant to be used.

For the http plugin, you’re best bet is to use angular’s http client and just handle CORs correctly on the server side.

Which is more advisable to use, Ionic Native Http or Angular’s own (which is not installed by default)?

Angular’s own should be installed by default, just not included in the module.

But use Angular’s over the native plugin.

1 Like

Hhmm, how strange, it is not installed, when I import it it tells me that there is no such module, I suppose I have to do it manually.

What would be the difference between Ionic Native’s own versus Angular’s Http client?

+ import { HttpClientModule } from '@angular/common/http';

  declarations: [AppComponent],
  imports: [
+    HttpClientModule,

  providers: [{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy }],
  bootstrap: [AppComponent],

There’s a lot that’s different, I would suggest reading over angular’s guide on http

Thank you very much for your time, it is appreciated.