first time working with a Lightning Web Component and Lightning Out so this may be a fairly simple question.

We're still using Salesforce Classic so I need to be able to use navigation methods which work in both Lightning and Classic. With that in mind, I've tried a few different methods to establish if the UITheme being displayed by the user is Lightning or Classic and none of them seem to work with the App and are resulting in undefined results mostly.

Scenario One (Using Salesforce new Javascript method from Summer 18):

isDesktopClassic() {
        return UITheme.getUITheme() === "Theme3";

This results in a Promise which doesn't seem to be what was expected. Perhaps I'm incorrect on that.

Scenario Two (Using Apex)

Helper Class:

@AuraEnabled (cacheable=true)
public static boolean getIsUserInClassic(){

    //Run class to see if the user is in Classic or Lightning
    String themeDisplayed = UserInfo.getUiThemeDisplayed();

    //Boolean for Classic
    boolean displayClassic = false;

    //Populate checkbox for handiness
    if (themeDisplayed == 'Theme3'){
        displayClassic = true;

    return displayClassic;                                  


Lightning Web Component:

import getIsUserInClassic from '@salesforce/apex/HelperClass.getIsUserInClassic';

export default class sampleClass extends NavigationMixin(LightningElement) {

@track isUserInClassic;


        .then(result => {
            this.isUserInClassic = result;
            this.error = undefined;
        }).catch(error =>{
            this.error = error;
            this.isUserInClassic = undefined;



Apologies if I'm missing something fairly rudimentary and thanks for taking a look!

  • 1
    What is not working here? As for the JS function, as seen in the docs it seems it should be UITheme.getUITheme == 'Theme3' (notice there's no parenthesis at the end), you can try that out.
    – Jayant Das
    May 21, 2019 at 22:06
  • I'm pretty sure that's just a typo in the documentation - earlier in the same documentation it says "The UITheme.getUITheme() JavaScript function". The error I'm getting using the Javascript method (my preferred approach) is that it's undefined. In Scenario Two - nothing happens when I try to utilize the isUserInClassic in my Lightning Out App.
    – cloudcap
    May 21, 2019 at 23:37
  • Where is your JS function defined/declared?
    – Jayant Das
    May 22, 2019 at 0:28
  • I'm attempting to do almost exactly the same thing and I'm having a similar issue. I'm thinking I'm going to need to rely on a custom Apex method and hold that as a class variable. Let me know if you want to share learnings.....
    – Bigears
    May 28, 2019 at 14:16


You must log in to answer this question.

Browse other questions tagged .