Hello Everyone, In this tutorial, we will know how a $Browser global variable works in Salesforce Lightning component. $Browser global value provider returns information about the hardware and operating system of the browser accessing the application. With the help of this global value provider, you can easily track with operating systems or browsers are accessing your application.

After completing this tutorial, you’ll able to:
  • How to use $Browser value provider in Lightning Component.
So let's start,

How to use $Browser in Lightning Component?

In Lightning Component -
 <aura:component>
    {!$Browser.isTablet}
    {!$Browser.isPhone}
    {!$Browser.isAndroid}
    {!$Browser.formFactor}
 </aura:component>
In client-side controller using $A.get() -
 ({
    checkBrowser: function(component) {
        var device = $A.get("$Browser.formFactor");
        alert("You are using a " + device);
    }
 })

Output:
See also:
Conclusion:
Hope you like this tutorial, for any query or suggestions please feel free to comment.
Thank you.