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?
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