Need storage, device access, or network data in a web app? Check the browser before adding a dependency. Web APIs, also called browser APIs, expose platform capabilities through JavaScript. The DOM is one such interface, not the whole set: other APIs are available through objects including `navigator`, `window`, and `document`. section 2.2.1 section 6.3
Choose the capability that matches the job:
- Use `fetch()` for data requests, the Cache API for offline caching, and the Performance API for measurements. section 2.2.1
- Consider storage, geolocation, clipboard, media, notifications, and hardware access where the feature calls for them. section 2.2.1 section 6.3
A Web API does not require a framework, but using one does not prevent direct browser access. Start with widely available APIs; treat experimental features as optional enhancements. Check compatibility in MDN Web Docs or Baseline, and test early on HTTPS or localhost: some APIs need a secure context and may fail or throw errors without one. section 1.5.1 section 2.2.1 section 6.3
if ('permissions' in navigator) {
navigator.permissions.query({name: "geolocation"})
.then(console.log);
}
The permission-query example first checks for `navigator.permissions`, then queries geolocation permission. It illustrates checking for an interface before using it; it is not a substitute for checking the capability’s other requirements. section 2.2.1 section 6.3
