WorkerNavigator: gpu property
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Secure context: This feature is available only insecure contexts (HTTPS), in some or allsupporting browsers.
Note: This feature is only available inWeb Workers.
Thegpu read-only property of theWorkerNavigator interface returns theGPU object for the current worker context, which is the entry point for theWebGPU API.
In this article
Value
AGPU object.
Examples
js
// Can be run inside a web workerasync function init() { if (!navigator.gpu) { throw Error("WebGPU not supported."); } const adapter = await navigator.gpu.requestAdapter(); if (!adapter) { throw Error("Couldn't request WebGPU adapter."); } const device = await adapter.requestDevice(); // …}Specifications
| Specification |
|---|
| WebGPU> # navigator-gpu> |