How can I detect the current operating system in my react js PWA project.I have used process.platform but it gives "undefined".Please help
Asked
Active
Viewed 3,827 times
3
-
You can refer this post: https://stackoverflow.com/questions/38241480/detect-macos-ios-windows-android-and-linux-os-with-js – Manoj Feb 11 '21 at 02:56
2 Answers
3
Your best bet is const platform = window.navigator.platform

Praveen Nambiar
- 4,852
- 1
- 22
- 31
-
It worked for me can you please give me the possible values for the operating systems – Sahan Thilakarathna Feb 11 '21 at 03:16
-
-
-
-
-
This is [deprecated](https://developer.mozilla.org/en-US/docs/Web/API/Navigator/platform) now. – bflemi3 Jan 11 '23 at 20:47
0
Values for the operating systems:
const platform = window.navigator.userAgentData.platform;

Navin
- 1
- 1
-
Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Nov 03 '22 at 09:14