JavaScript Navigator gpu Property

Beginner
⏱️ 10 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
Limited support
Secure context

What You’ll Learn

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()

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.

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.

📝 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
}

⚡ Quick Reference

GoalCode
Get WebGPU entrynavigator.gpu
Detect API"gpu" in navigator && navigator.gpu
Request adapterawait navigator.gpu.requestAdapter()
Request deviceawait adapter.requestDevice()
Preferred canvas formatnavigator.gpu.getPreferredCanvasFormat()
Secure page?window.isSecureContext
Status (MDN)Limited / not Baseline

🔍 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

📋 WebGPU vs WebGL

WebGPU (navigator.gpu)WebGL
Entrynavigator.gpucanvas.getContext("webgl")
EraModern GPU + computeOlder, very widely supported
ModelAdapter → device → resourcesGL context + draw calls
ComputeFirst-class GPU computeLimited / workarounds
FallbackOften fall back to WebGL / Canvas 2DCommon default for 3D

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.

JavaScript
const supported = Boolean(navigator.gpu);
console.log(supported ? "WebGPU available" : "WebGPU missing");
Try It Yourself

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");
}
Try It Yourself

How It Works

Localhost counts as a secure context for development. Plain http:// on a remote host will not.

📈 Practical Patterns

Request an adapter, then a device — MDN’s core init flow.

Example 3 — Request an Adapter

Ask for a GPUAdapter. It may be null even when navigator.gpu exists.

JavaScript
async function getAdapter() {
  if (!navigator.gpu) {
    return "WebGPU not supported.";
  }
  const adapter = await navigator.gpu.requestAdapter();
  if (!adapter) {
    return "Couldn't request WebGPU adapter.";
  }
  return "Adapter ready: " + (adapter.info?.description || "ok");
}

getAdapter().then(console.log);
Try It Yourself

How It Works

Hardware, drivers, OS, or browser flags can block an adapter. Always null-check before requestDevice().

Example 4 — Request a Device

Full MDN-style init: detect → adapter → device.

JavaScript
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();
  return "Device ready: " + device.label;
}

init()
  .then(console.log)
  .catch(function (err) {
    console.log(String(err.message || err));
  });
Try It Yourself

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()));
Try It Yourself

How It Works

getPreferredCanvasFormat() helps you configure a <canvas> for WebGPU presentation when the API exists.

🚀 Common Use Cases

  • 3D games & scenes — modern rendering pipelines via WebGPU.
  • GPU compute — ML inference, physics, image filters in the browser.
  • Feature gating — enable a “high performance” path only when navigator.gpu exists.
  • Canvas presentation — use preferred format + device for crisp GPU-backed canvases.
  • Progressive enhancement — WebGPU when available; WebGL / 2D otherwise.

🧠 How navigator.gpu Works

1

Check the entry point

navigator.gpu must exist in a secure context.

Detect
2

Request an adapter

requestAdapter() picks a usable GPU (or returns null).

Adapter
3

Request a device

requestDevice() gives your working GPUDevice.

Device
4

Create GPU work

Buffers, pipelines, and command queues — or fall back if any step fails.

📝 Notes

  • Limited availability / not Baseline — support varies by browser and OS.
  • Not Deprecated, Experimental, or Non-standard on MDN — no status banner on this page.
  • Secure context required (HTTPS / localhost).
  • requestAdapter() can return null — always check before requestDevice().
  • Related: hardwareConcurrency, deviceMemory, JavaScript hub.

Limited Browser Support

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.

Limited Not Baseline
Google Chrome WebGPU on Windows / macOS / ChromeOS (113+); Android & Linux evolving
Supported*
Microsoft Edge Chromium Edge — follows Chrome WebGPU rollouts
Supported*
Opera Chromium-based — WebGPU where Chromium enables it
Supported*
Mozilla Firefox Shipping on some platforms (e.g. Windows); others still rolling out
Partial
Apple Safari WebGPU in recent Safari / iOS versions — check target OS
Partial
gpu Limited

Bottom line: Use navigator.gpu over HTTPS, null-check adapters, and never assume every visitor has WebGPU.

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.

Continue with hardwareConcurrency, deviceMemory, or the JavaScript hub.

💡 Best Practices

✅ Do

  • Feature-detect navigator.gpu first
  • Serve over HTTPS / localhost
  • Null-check the adapter before requestDevice()
  • Keep a WebGL or 2D fallback
  • Handle async errors with try/catch or .catch()

❌ Don’t

  • Assume every browser exposes WebGPU
  • Skip adapter null checks
  • Require WebGPU for core site content
  • Ignore lost-device / error events in real apps
  • Test only on one OS + GPU combination

Key Takeaways

Knowledge Unlocked

Five things to remember about gpu

WebGPU entry point — detect, adapt, then request a device.

5
Core concepts
🔒 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.

Explore hardwareConcurrency Next

Learn logical CPU counts for sizing Web Worker pools.

hardwareConcurrency →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful