Lightning Aura Components – Lightning Record Edit Form Not Redirecting to Detail Page After Save

After saving contact details, record is saved but it's not redirecting to contact detail page.

<aura:component implements="force:appHostable" >
<aura:attribute name="recordId" type="String" />
<div class="slds-p-bottom_large slds-p-left_large" style="width:500px">
    <lightning:recordEditForm objectApiName="Contact">
        <lightning:messages />
        <lightning:inputField fieldName="FirstName" />
        <lightning:inputField fieldName="LastName" />
        <lightning:inputField fieldName="Birthdate" />
        <lightning:inputField fieldName="Phone" />
        <lightning:button aura:id="submit" type="submit" label="Save record" class="slds-m-top_medium" />
        </lightning:recordEditForm>
</div>  

Best Answer

That’s because you have to code the redirection using the onsuccess event. The default behaviour is , does nothing on save, you will have to retrieve the Id of the record from the response object and use it to redirect to the appropriate record detail page/view. The component documentation has several code snippets that will help you achieve the functionality.