navigator.gpu is the entry point for the WebGPU API. Learn the GPU object, secure context rules, requestAdapter / requestDevice, five beginner examples, and try-it labs.
01
Kind
Read-only property
02
Returns
GPU object
03
Baseline
Not Baseline
04
Context
Secure (HTTPS)
05
Next step
requestAdapter()
06
Then
requestDevice()
Fundamentals
Introduction
WebGPU lets web apps use the graphics card for fast 3D rendering and GPU compute (machine learning, simulations, image processing). Before you draw anything, you need the API’s front door.
navigator.gpu is that door. When WebGPU is available, it returns a GPU object for the current browsing context. From there you request an adapter (the physical/logical GPU) and a device (your working handle for creating buffers, pipelines, and commands).
💡
Start small
This page focuses on detecting WebGPU and getting a device — the same first steps as MDN’s example. Full shaders, canvases, and compute passes come after you have a working GPUDevice.
Concept
Understanding the gpu Property
Think of navigator.gpu as the WebGPU “reception desk.” It does not draw triangles by itself — it hands you the objects that can.
GPU object — entry point returned by navigator.gpu.
Adapter — from gpu.requestAdapter(); may be null.
Device — from adapter.requestDevice(); where real work starts.
Secure context — HTTPS / localhost required in supporting browsers.
Missing property — browser or platform does not expose WebGPU — feature-detect.
Foundation
📝 Syntax
General form of the property:
JavaScript
navigator.gpu
Value
A GPU object when WebGPU is supported in this context.
undefined (property missing) when WebGPU is not available.
Common patterns
JavaScript
// MDN-style init (simplified):
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.");
}
const device = await adapter.requestDevice();
// Use device for buffers, pipelines, command encoding…
}
// Safe feature-detect without throwing:
if ("gpu" in navigator && navigator.gpu) {
// WebGPU entry point is available
}
Cheat Sheet
⚡ Quick Reference
Goal
Code
Get WebGPU entry
navigator.gpu
Detect API
"gpu" in navigator && navigator.gpu
Request adapter
await navigator.gpu.requestAdapter()
Request device
await adapter.requestDevice()
Preferred canvas format
navigator.gpu.getPreferredCanvasFormat()
Secure page?
window.isSecureContext
Status (MDN)
Limited / not Baseline
Snapshot
🔍 At a Glance
Four facts to remember about navigator.gpu.
Returns
GPU
WebGPU entry
Baseline
no
Limited support
HTTPS
required
Secure context
First call
requestAdapter()
Then device
Compare
📋 WebGPU vs WebGL
WebGPU (navigator.gpu)
WebGL
Entry
navigator.gpu
canvas.getContext("webgl")
Era
Modern GPU + compute
Older, very widely supported
Model
Adapter → device → resources
GL context + draw calls
Compute
First-class GPU compute
Limited / workarounds
Fallback
Often fall back to WebGL / Canvas 2D
Common default for 3D
Hands-On
Examples Gallery
Examples follow MDN navigator.gpu / WebGPU init patterns. Prefer Try It Yourself on HTTPS. Adapter/device steps need a supporting browser and GPU.
📚 Getting Started
Detect WebGPU and confirm a secure context.
Example 1 — Feature Detection
Check whether the WebGPU entry point exists on navigator.
WebGPU missing
(or "WebGPU available" in a supporting browser)
How It Works
MDN’s pattern is if (!navigator.gpu). Same idea: treat a missing entry point as unsupported.
Example 2 — Secure Context Check
WebGPU requires a secure context — confirm HTTPS / localhost together with the API.
JavaScript
console.log("secure: " + window.isSecureContext);
console.log("gpu: " + Boolean(navigator.gpu));
if (!window.isSecureContext) {
console.log("Serve over HTTPS to use WebGPU");
} else if (!navigator.gpu) {
console.log("Secure, but WebGPU not exposed");
} else {
console.log("Ready to request an adapter");
}
WebGPU not supported.
(or "Device ready: …" when WebGPU works)
How It Works
Once you have a GPUDevice, you can create buffers, textures, pipelines, and encode GPU commands.
Example 5 — Capability Helper
Bundle detection, preferred canvas format, and a short status for dashboards or fallbacks.
JavaScript
function webgpuStatus() {
const available = Boolean(navigator.gpu);
return {
available: available,
secureContext: window.isSecureContext,
preferredCanvasFormat: available
? navigator.gpu.getPreferredCanvasFormat()
: null,
advice: available
? "Call requestAdapter() then requestDevice()"
: "Fall back to WebGL or Canvas 2D"
};
}
console.log(JSON.stringify(webgpuStatus()));
navigator.gpu (WebGPU) is not Baseline. Availability depends on browser and platform (GPU drivers, OS). Always feature-detect and keep a WebGL / Canvas fallback for production.
✓ Limited · Not Baseline
Navigator.gpu
Entry point for WebGPU. Detect the GPU object, request an adapter and device, and degrade gracefully when unsupported.
LimitedNot Baseline
Google ChromeWebGPU on Windows / macOS / ChromeOS (113+); Android & Linux evolving
Supported*
Microsoft EdgeChromium Edge — follows Chrome WebGPU rollouts
Supported*
OperaChromium-based — WebGPU where Chromium enables it
Supported*
Mozilla FirefoxShipping on some platforms (e.g. Windows); others still rolling out
Partial
Apple SafariWebGPU in recent Safari / iOS versions — check target OS
Partial
gpuLimited
Bottom line: Use navigator.gpu over HTTPS, null-check adapters, and never assume every visitor has WebGPU.
Wrap Up
Conclusion
navigator.gpu is the WebGPU entry point. Feature-detect it in a secure context, call requestAdapter() then requestDevice(), and keep a fallback for browsers without GPU support.
WebGPU entry point — detect, adapt, then request a device.
5
Core concepts
🖥01
Returns
GPU object
Entry
🔒02
HTTPS
Secure context
Required
💻03
Adapter
May be null
Check
⚙04
Device
Real GPU work
Next
🔬05
Status
Not Baseline
Detect
❓ Frequently Asked Questions
It is a read-only Navigator property that returns the GPU object for the current browsing context — the entry point for the WebGPU API.
MDN does not mark it Deprecated, Experimental, or Non-standard. It is Limited availability / not Baseline — missing or incomplete on some browsers and platforms. Always feature-detect.
Yes. navigator.gpu is available only in secure contexts (HTTPS or localhost) in supporting browsers.
GPU.requestAdapter() asks the browser for a GPUAdapter that represents the user’s GPU. If none is available, it may resolve to null — always check the result.
WebGL is the older, widely supported graphics API. WebGPU is the modern successor for high-performance graphics and GPU compute, with a different object model (adapter → device → queues/resources).
No. It is read-only. You use the returned GPU object to request adapters and devices; you do not assign to navigator.gpu.
Did you know?
Having navigator.gpu is not enough — MDN’s example still checks that requestAdapter() returns a real adapter. Some devices expose the API but cannot provide a usable GPU.