How to get desktop OS (Windows/macOS/linux) with Capacitor?

Is there any way to get the desktop OS with Capacitor?

To check if iOS or Android, there is the getPlatform method.

But for the desktop, I want to know if the OS is Windows, Linux, or macOS.

Does Capacitor provide any way to do that?

Assuming you are talking about web platform and not electron or other custom platform you have created, Device plugin has a operatingsystem property returned by Device.getInfo();, but might not be very reliable since it’s “guessed” from the navigator user agent.

1 Like