files/en-us/web/api/gpudevice/destroy/index.md
{{APIRef("WebGPU API")}}{{SecureContext_Header}}{{AvailableInWorkers}}
The destroy() method of the
{{domxref("GPUDevice")}} interface destroys the device, preventing further operations on it.
Note that:
destroy()
None.
None ({{jsxref("undefined")}}).
async 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.");
}
let device = await adapter.requestDevice();
// Some time later
device.destroy();
}
{{Specifications}}
{{Compat}}