JavaScript Navigator preferences Property

Beginner
⏱️ 10 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
Experimental

What You’ll Learn

navigator.preferences returns a PreferenceManager for the current document. Learn MDN’s colorScheme.value check, related preference objects, secure-context notes, matchMedia fallbacks, five examples, and try-it labs.

01

Kind

Read-only property

02

Returns

PreferenceManager

03

Status

Experimental

04

Example

colorScheme

05

Context

Often HTTPS

06

Fallback

matchMedia

Introduction

Users set system preferences for dark mode, reduced motion, contrast, and more. CSS already exposes many of these via prefers-* media queries. The experimental User Preferences API adds a JavaScript entry point on navigator.preferences.

Reading navigator.preferences gives you a PreferenceManager. From there you can inspect preference objects such as colorScheme (for example .value === "dark" or "light").

💡
Progressive enhancement

Treat this API as optional. Most sites can already theme with @media (prefers-color-scheme: dark) or matchMedia("(prefers-color-scheme: dark)").

Understanding the preferences Property

navigator.preferences is not a Boolean. It is a manager object for user preference media settings. MDN lists PreferenceManager accessors such as:

  • colorScheme — dark / light style preference.
  • contrast — contrast preference.
  • reducedMotion — reduced motion preference.
  • reducedTransparency — reduced transparency preference.
  • reducedData — reduced data preference.
  • Experimental — feature-detect; do not require it for core UX.

📝 Syntax

General form of the property:

JavaScript
navigator.preferences

Value

  • A PreferenceManager object for the current document.

Common patterns

JavaScript
// Always feature-detect first
if (navigator.preferences) {
  // MDN color scheme check:
  if (navigator.preferences.colorScheme.value === "dark") {
    console.log("dark");
  } else {
    console.log("light");
  }
} else {
  // Widely available fallback:
  const dark = window.matchMedia("(prefers-color-scheme: dark)").matches;
  console.log(dark ? "dark (via matchMedia)" : "light (via matchMedia)");
}

⚡ Quick Reference

GoalCode
Get PreferenceManagernavigator.preferences
Feature detect"preferences" in navigator
Color scheme valuenavigator.preferences.colorScheme.value
Dark?=== "dark"
FallbackmatchMedia("(prefers-color-scheme: dark)")
Writable?No (read-only property)
Status (MDN)Experimental

🔍 At a Glance

Four facts to remember about navigator.preferences.

Returns
PreferenceManager

API entry point

Status
experimental

Not Baseline

Example
colorScheme

dark / light

Fallback
matchMedia

prefers-*

📋 navigator.preferences vs matchMedia

navigator.preferencesmatchMedia("(prefers-…)")
MaturityExperimentalWidely available
Access stylePreferenceManager objectsMediaQueryList Boolean / events
Can override?API may support requestOverride()Read-only observation
Production defaultOptional enhancementRecommended baseline
Use together?Yes — try preferences when present; always keep matchMedia / CSS fallbacks

Examples Gallery

Examples follow MDN navigator.preferences patterns with safe detection. Prefer Try It Yourself. Many browsers still report the API as missing.

📚 Getting Started

Detect support and read MDN’s color scheme example.

Example 1 — Feature Detection

Check whether preferences exists before reading it.

JavaScript
const supported = "preferences" in navigator && !!navigator.preferences;
console.log(supported ? "preferences available" : "preferences missing");
Try It Yourself

How It Works

On most current browsers this logs missing. Keep CSS / matchMedia paths for everyone else.

Example 2 — MDN colorScheme.value Check

Branch on dark vs light when the API exists.

JavaScript
function describeColorScheme() {
  if (!navigator.preferences || !navigator.preferences.colorScheme) {
    return "preferences.colorScheme not available";
  }
  if (navigator.preferences.colorScheme.value === "dark") {
    return "dark";
  }
  return "light";
}

console.log(describeColorScheme());
Try It Yourself

How It Works

Matches MDN’s example, with a guard so unsupported browsers stay clear and beginner-friendly.

📈 Practical Patterns

Secure contexts, matchMedia fallbacks, and a reusable helper.

Example 3 — Secure Context Check

Related PreferenceManager features often require HTTPS.

JavaScript
const lines = [];
lines.push("isSecureContext: " + window.isSecureContext);
lines.push(
  "preferences: " +
    ("preferences" in navigator && navigator.preferences ? "present" : "absent")
);
console.log(lines.join("\n"));
Try It Yourself

How It Works

Secure context is often necessary but not sufficient — the API can still be missing.

Example 4 — matchMedia Fallback

Use the widely available prefers-color-scheme query when preferences is absent.

JavaScript
function preferredScheme() {
  if (navigator.preferences && navigator.preferences.colorScheme) {
    return {
      source: "navigator.preferences",
      value: navigator.preferences.colorScheme.value
    };
  }
  const dark = window.matchMedia("(prefers-color-scheme: dark)").matches;
  return {
    source: "matchMedia",
    value: dark ? "dark" : "light"
  };
}

console.log(JSON.stringify(preferredScheme()));
Try It Yourself

How It Works

This pattern keeps theme logic working everywhere while adopting the experimental API when present.

Example 5 — Preference Snapshot Helper

Collect a small debug object without throwing when fields are missing.

JavaScript
function preferencesSnapshot() {
  if (!navigator.preferences) {
    return { ok: false, reason: "api-missing" };
  }
  const keys = [
    "colorScheme",
    "contrast",
    "reducedMotion",
    "reducedTransparency",
    "reducedData"
  ];
  const values = {};
  for (const key of keys) {
    try {
      const obj = navigator.preferences[key];
      values[key] = obj && "value" in obj ? obj.value : null;
    } catch (err) {
      values[key] = null;
    }
  }
  return { ok: true, values };
}

console.log(JSON.stringify(preferencesSnapshot(), null, 2));
Try It Yourself

How It Works

Useful for diagnostics. Never assume every PreferenceManager field exists in every experimental build.

🚀 Common Use Cases

  • Theme experiments — read colorScheme.value when the API exists.
  • Site-level overrides — explore requestOverride() where supported (still experimental).
  • Accessibility labs — inspect reduced motion / contrast preferences in supporting browsers.
  • Diagnostics — log a preference snapshot in debug panels.
  • Not a CSS replacement — keep prefers-* media queries as the default path.

🧠 How navigator.preferences Works

1

Browser may expose the API

Experimental — often absent today.

Detect
2

Return PreferenceManager

Entry point for preference objects like colorScheme.

Manager
3

Read .value

For example "dark" or "light".

value
4

Keep CSS / matchMedia

Production themes should still work without this API.

📝 Notes

  • Experimental on MDN — not Baseline.
  • Not labeled Deprecated or Non-standard on the property page; still treat as unstable.
  • Read-only entry point returning PreferenceManager.
  • Related features may require a secure context (HTTPS / localhost).
  • Prefer CSS prefers-* and matchMedia for production defaults.
  • Related: platform, permissions, Window, JavaScript hub.

Limited / Experimental Support

navigator.preferences is Experimental and not Baseline. Support is limited and evolving. Always feature-detect and keep matchMedia / CSS prefers-* fallbacks.

Experimental · Not Baseline

Navigator.preferences

Safe to explore for learning. Do not require the User Preferences API for core theming or accessibility.

Limited Experimental
Google Chrome Check current experimental / flag status
Limited
Mozilla Firefox Typically unavailable — use matchMedia
Unavailable
Apple Safari Typically unavailable — use matchMedia
Unavailable
Microsoft Edge Follow Chromium experimental status
Limited
Opera Follow Chromium experimental status
Limited
Internet Explorer No User Preferences API support
Unavailable
preferences Limited

Bottom line: Feature-detect navigator.preferences, try colorScheme when present, and rely on matchMedia/CSS prefers-* for everyone else.

Conclusion

navigator.preferences is an experimental entry point to PreferenceManager. Learn MDN’s colorScheme.value pattern, feature-detect carefully, and keep CSS / matchMedia as your production baseline.

Continue with presentation, permissions, or the JavaScript hub.

💡 Best Practices

✅ Do

  • Feature-detect before reading preferences
  • Keep CSS prefers-* as the default path
  • Fall back to matchMedia in JavaScript
  • Test on HTTPS when experimenting with overrides
  • Treat values as progressive enhancement

❌ Don’t

  • Require this API for dark mode to work
  • Assume every PreferenceManager field exists
  • Skip feature detection
  • Try to assign to navigator.preferences
  • Ship experimental overrides without graceful fallbacks

Key Takeaways

Knowledge Unlocked

Five things to remember about preferences

Experimental PreferenceManager — enhance, do not depend.

5
Core concepts
🌙 02

Example

colorScheme

API
⚗️ 03

Status

experimental

Caution
🔒 04

HTTPS

often required

Context
🎯 05

Fallback

matchMedia

Reliable

❓ Frequently Asked Questions

It is a read-only Navigator property that returns a PreferenceManager object — the entry point to the experimental User Preferences API for reading (and sometimes overriding) user preference media settings such as color scheme.
MDN marks it Experimental. It is not Baseline. Always feature-detect and keep a fallback such as CSS prefers-* media queries or window.matchMedia.
MDN’s pattern: if (navigator.preferences.colorScheme.value === "dark") { /* dark */ } else { /* light */ }. Feature-detect navigator.preferences first.
PreferenceManager can provide PreferenceObject accessors such as colorScheme, contrast, reducedMotion, reducedTransparency, and reducedData — corresponding to prefers-* media queries.
Related PreferenceManager / PreferenceObject features are documented as secure-context (HTTPS or localhost) in supporting browsers. Prefer testing on HTTPS.
No. The property is read-only. You use the returned PreferenceManager and its PreferenceObject methods (for example requestOverride where supported).
Did you know?

The User Preferences API is designed to align with CSS preference media queries such as prefers-color-scheme and prefers-reduced-motion — giving JavaScript a structured way to read (and sometimes override) the same ideas.

Learn presentation Next

Experimental Presentation API entry point for casting flows.

presentation →

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