Determine what device or user agent a user is using

Is there anyway to determine what device, browser, or something similar the user is on? I’d ideally like to know whether the user is on a Mac, Windwos, Linux, iOS, or Android device.

That way I can use a template to modify the URL of a Lovelace link to use an app specific URL if on a smartphone or a web based url if on a computer.

Any ideas?

Any ideas for anything? Even if not exact but similar?