I'm developing a Community and I have a custom Login Aura controller. To log in the user I use the standard Site.login() method that returns a pageReference, that then is passed to aura.redirect()

Login Controller:

ApexPages.PageReference lgn = Site.login(username, password, startUrl);

aura.redirect() won't navigate to Home and it doesn't throw an error either.

I've also tried to navigate to Home using NavigationMixin.Navigate but it doesn't work either.

I send a response from my controller to my LWC and there in the component I try to navigate from the login page to Home using the following code, but it just won't work


        type : 'standard__namedPage',
        attributes : {
            pageName : 'home'

Any ideas on how to log in the user and then take the user from the community login page to Home using LWC?

  • Try wrapping your login lwc component in a standard Aura one... then all your UI can be lwc, but hopefully the call to the back end will go through the standard Aura framework. Commented Jun 9, 2019 at 19:36

4 Answers 4


In Summer '19, Salesforce enhanced the support of lightning-navigation in Community with comm__namedPage (instead of standard__namedPage), pageReferences and state.


export default class myClass extends NavigationMixin(LightningElement) {

 goToFAQCategoryMesInstallations() {
   type: 'comm__namedPage',
   attributes: {
    pageName: 'faq',
   state: {
    'category': 'Mes_installations'

this will redirect you to 'yourCommunity'/s/faq?category=Mes_installations

  • That's absolutely correct, thanks for this.
    – Arthlete
    Commented Dec 26, 2019 at 19:55
  • hi @Olivier, I tried to use this code, but unfortunately if I call it from login page it redirects to 'mycommunity'/s/login/faq and not to 'mycommunity'/s/faq :( The same for "home" parameter, it redirects to login page, not the home. Any ideas for this?
    – jm.
    Commented Jan 24, 2020 at 12:41

Well after doing some research I found out that apparently and according to René Winkelmeyer (Salesforce Principal Developer Evangelist) in this GitHub Issue:

lightning-navigation is currently not a supported experience for Communities.

  • I would say that lightning-navigation partially works, it allows to route pages but when you used for authentication it does not work. You can try @Rui Viera solution, that one worked for me. Commented Aug 11, 2020 at 21:17

Found the solution (workaround) for this, you can return the url of the PageReference retrieved from Site.login(), then you'll just need to window.open(url, '_self') in the Component's js. As for the PageReference itself it is not a valid type to be returned by AuraEnabled methods.


You can pass startUrl with portal name where you want to redirect. Like if portal url is https://****-****.cs77.force.com/customerportal then you can pass /customerportal/s in starturl. This will redirect you to home page after validation.

   //startUrl -- put portal name in this variable 
   ApexPages.PageReference lgn = Site.login(username, password, startUrl);
   return null;                

You must log in to answer this question.

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