deleteRecord(recordId)

Deletes a record.

deleteRecord uses this User Interface API resource.

  • recordId—(Required) The ID of the record to delete.

The return type is void.

There are several ways to use deleteRecord. For example, you can display a list of records and enable deletion on each record on the list. See the ldsDeleteRecord component in the lwc-recipes GitHub repo.

This example adds a delete button to a record page. Deleting a record displays a toast message using the lightning/platformShowToastEvent module. The user is redirected to the record home page after record deletion using lightning/navigation.

This button calls the delete() method.