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.


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';

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

connectedCallback() {
        document.title = 'Test Me Please';    
  • 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. – Renato Oliveira Nov 23 '20 at 13:22
  • 1
    Why is it not possible to use settimeout in lwc? Any reason? – Nagendra Singh Nov 23 '20 at 13:27
  • It is explained in this other Q&A: salesforce.stackexchange.com/questions/261416/… – Renato Oliveira Nov 23 '20 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 – Nagendra Singh Nov 23 '20 at 14:42
  • Hi @NagendraSingh, document.title did the trick (without setTimeout), thank you. – Json Nov 23 '20 at 14:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.