Web APIs

Web APIs provide access to native device and platform functionalities to the web apps via JavaScript.

These Web APIs are standardized by W3C, therefore are in-built in the web browsers.

There are a large number of Web APIs available. You can learn about them at https://developer.mozilla.org/en-US/docs/Web/API

Nectar provides demo for a number of useful Web APIs which are commonly used in PWAs.

You can check them at https://nectar.website/demo/web-apis/

Most of the Web APIs require SSL, ie, the website must be served from HTTPS. On localhost you can use Web APIs without SSL, but on production server, you must have SSL installed.

Not all the Web APIs are supported by every browser, therefore it is necessary to check if a particular Web API is supported on the targeted browser platform.

We have provided a helper utility function to check the Web API for browser support. You can find the code in /assets/custom/js/init.js file, inside app.support.webApi = {} object.

In case, the Web API is not supported on your targeted browser platform, you should provide a proper fallback for that by using some third-party library or polyfill.

Most of the Web APIs also work in Cordova, as Cordova uses WebViews. In case they do not work, you can always use Cordova-specific plugins for that.

While testing Web APIs, you might need to accept permission for some of the APIs. If you deny the permission, you will have to reset them from the browser's settings.

Last updated