How to detect windows 11 from user agent?

Viewed 6520

How I can figure out if someone opens my website in windows 11?

I test user agent and when someone opens my website with windows 11 I will get this

"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Firefox/91.0"

So technically this says it's windows 10, not 11.

Is there any way to detect this?

3 Answers

Using the User-Agent string to detect the browser and operating system is not reliable and is a legacy practice. You won't be able to detect Windows 11 because Windows 11 will use "Window NT 10.0" which is the same that Windows 10 uses.

But you can use User-Agent client hints in new browsers like Edge 94+ and Chrome 95+.

For Windows 11, look for these request headers:

Sec-CH-UA-Platform set to 'Windows'
Sec-CH-UA-Platform-Version set to 13.0.0 and above

See this link for more information: Detecting Windows 11 using User-Agent Client Hints

Works only on Edge browswer as far as I can tell. Adding the response header "Accept-CH:Sec-CH-UA-Platform-Version" returns [Sec-Ch-Ua-Platform-Version] => "14.0.0"

...but this is not supplied by Chrome or Firefox.

AFAIK you can't detect Windows 11 except with Edge.

Related