[SalesForce] Change browser title in Lightning Experience

I want to change the default browser title when the user press my Lightning Component Tab. How can I do it?

In visualforce, I had the title attribute <apex:page title="My title">, but in Lightning Experience I found no way to accomplish this, the title is always Lightning Experience | Salesforce:

Browser title

Any ideas?

Best Answer

You should do that in init handler of component.

Sample:

cmp file:

<aura:component implements="lightning:actionOverride,force:appHostable,flexipage:availableForRecordHome,force:hasRecordId,force:lightningQuickAction,lightning:isUrlAddressable" access="GLOBAL">

    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />

</aura:component>

controller JS:

({
    doInit : function(component, event, helper){
        document.title = "My Custom Component";
    }
});

Output:

enter image description here

Related Topic