I have a lightning component thats used in LEX, Classic, and a community. The component redirects the user to a record detail page after an action occurs. I am trying to implement UserInfo.getUiThemeDisplayed() to redirect the user to the correct place depending on the UI theme they are on.

However, in the lightning community it's returning theme3 as the value, I am expecting PortalDefault or Theme4d in the correct themes list


var locationAction = component.get('c.getLocationTheme');
locationAction.setCallback(this, function(response) {
    console.log('Location: ' + response.getReturnValue());


public static String getLocationTheme() {
    return UserInfo.getUIThemeDisplayed();

Debug: Location: Theme3

Is this expected behavior? What is the correct way of knowing where your lightning component instance is?

1 Answer 1


Ended up just writing my own method to get around it.

public static String getLocationTheme() {
    if (Site.getSiteId() != null) {
        return COMMUNITY;
    } else if (UserInfo.getUIThemeDisplayed() == 'Theme3') {
        return CLASSIC;
    } else {
        return LEX;

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .