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 in secure contexts (HTTPS), in some or all supporting browsers.
Note: This feature is available in Web Workers.
The getConfiguration() method of the GPUCanvasContext interface returns the current configuration set for the context.
getConfiguration()
None.
An object containing the configuration options set on the context (i.e., via the GPUCanvasContext.configure() method), or null if no configuration is set (either no configuration was previously set, or a configuration was set and then GPUCanvasContext.unconfigure() was called on the context).
const canvas = document.querySelector("canvas");
const context = canvas.getContext("webgpu");
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();
context.configure({
device,
format: navigator.gpu.getPreferredCanvasFormat(),
alphaMode: "premultiplied",
});
console.log(context.getConfiguration());
/* Logs something like:
{
"alphaMode": "premultiplied",
"colorSpace": "srgb",
"device": { ... },
"format": "bgra8unorm",
"toneMapping": {
"mode": "standard"
},
"usage": 16,
"viewFormats": []
}
*/
| Specification |
|---|
| WebGPU> # dom-gpucanvascontext-getconfiguration> |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
getConfiguration |
131Currently supported on ChromeOS, macOS, and Windows only. |
131Currently supported on ChromeOS, macOS, and Windows only. |
141Currently supported on Windows only, in all contexts except for service workers. |
116Currently supported on ChromeOS, macOS, and Windows only. |
26 | 131Currently supported on ChromeOS, macOS, and Windows only. |
No | 87Currently supported on ChromeOS, macOS, and Windows only. |
26 | No | 131Currently supported on ChromeOS, macOS, and Windows only. |
26 |
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/GPUCanvasContext/getConfiguration