I have configured a Custom Menu on the header component on my Community(Napili template) using lightning:buttonMenu and had Logout as one of the menu items. Clicking on it, it would then redirect to a page(I call it as Logout screen).

if(selectedMenuItemValue == 'Logout'){
       var urlEvent = $A.get("e.force:navigateToURL");
             "url": '/logout' 

But how can I actually implement a Logout that happens from Standard Logout item from Community's default Profile Header?

  • 2
    Use "/secur/logout.jsp" Also if navigateToURL is not working then have a simple <a href> link and construct the ULR like this: SalesforceOrgURL+CommunityPrefix+'/secur/logout.jsp' Good idea is to keep the Org and Community in the custom label and construct them in the component as: <a href="{!$Label.c.OrgURL+'/'+$Label.c.Community_Prefix+'/'+'secur/logout.jsp'}" Logout </a> May 15 '17 at 4:14
  • I am afraid it didn't worked. It said: Invalid Page. What I did was, changed the url in my code to yours. (< _ >)
    – Arnold Jr.
    May 15 '17 at 4:23
  • Can you please provide the code snippet? I am doing exactly the same and its working May 15 '17 at 4:26
  • Oh I missed your new edit. Let me try that and get back to you soon.
    – Arnold Jr.
    May 15 '17 at 4:28
  • @JaiChaturvedi As I mentioned, Logout is one of the menu items <lightning:menuItem> under <lightning:buttonMenu>. I couldn't use a <a href> tag as its not working with buttonMenu tag. Is there any other work around? Thanks
    – Arnold Jr.
    May 15 '17 at 4:40

I would use window.location.href=salesforceurl/secure/logout.jsp

This will use the current window to navigate to logout url

  • 2
    Cool. Working as I desired. Thank you for that. I would also appreciate @JaiChaturvedi for providing me insight on the possible solution.
    – Arnold Jr.
    May 15 '17 at 5:49

you can also add additional parameter like:


to redirect the user to home page of your application after successful logout.

  • 1
    I used this approach in my lightning component's controller. It logged out, but it didn't redirect to google. Is there any other approach to do the redirection?
    – SamuelDev
    Mar 24 '18 at 4: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.