0

I have a LWC that runs inside a custom SF tab, I want to know how to change the browser tab name ?

I only managed to find this answer but it is for aura.

1 Answer 1

2

document.title still works fine, the issue is it gets overriden by the record name if the lwc component is on a record page, rest for an app page it works fine.

So you can try giving it a timeout if its a record page.

connectedCallback() {
    setTimeout(function (){
        document.title = 'Test Me Please';
    },10000);
}

Or just try by removing the settimout if its a app page:

connectedCallback() {
        document.title = 'Test Me Please';    
}
6
  • 2
    It is not possible to use "setTimeout" in a LWC though. I'd say it is not worth the effort to rename the tab at all. Nov 23, 2020 at 13:22
  • 1
    Why is it not possible to use settimeout in lwc? Any reason? Nov 23, 2020 at 13:27
  • It is explained in this other Q&A: salesforce.stackexchange.com/questions/261416/… Nov 23, 2020 at 14:25
  • 1
    Its just a es-lint plugin which gives a warning. Though from LWC its not restricted, though for above scenario as its a custom app, I think there is not need of setTimeout Nov 23, 2020 at 14:42
  • Hi @NagendraSingh, document.title did the trick (without setTimeout), thank you.
    – Json
    Nov 23, 2020 at 14:50

You must log in to answer this question.

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