How to detect if a user is in Salesforce1 vs Lightning Desktop

Has anyone figured out a way to differentiate between Lightning Desktop and Salesforce1?

There are mechanisms to detect if a user is using Lightning Desktop / Salesforce1 vs Salesforce Classic (Aloha). See here for a Javascript solution.

I know officially (same link – see ‘Limitations of Detecting’) there is no supported mechanism yet. I’ve also read about the Visualforce workaround that is out at the moment.

I want to know specifically a front end way to tell the two interfaces apart.



With Spring 16 release, we are getting new values added to the existing $User.UITheme Global variable and to the UserInfo.getUiTheme() method which will help us to identify the current user’s UI mode.

here’s the list of possible values

  • Theme1 — Obsolete Salesforce theme
  • Theme2 — Salesforce Classic 2005 user interface theme
  • Theme3 — Salesforce Classic 2010 user interface theme
  • Theme4d — Modern “Lightning Experience” Salesforce theme
  • Theme4t — Salesforce1 mobile Salesforce theme
  • PortalDefault — Salesforce Customer Portal theme
  • Webstore — Salesforce AppExchange theme

hopefully we can use this in Workflows, Validations, Formulas, Apex & Visualforce..

Official Reference

Source : Link , Question Author : Nelson Ramalho , Answer Author : Vamsi Krishna Gosu

Leave a Comment