Delete a Post
This guide will help you delete a post from a Lens Feed.
To delete a post on Lens, you need to:
Delete the Post on-chain
Wait for the transaction to be finalized
Delete the Post content
- TypeScript
- GraphQL
- React
First, use the deletePost action to submit/create a delete transaction.
Bear in mind that the trail of the Post existance will remain as part of the blockchain history.
import { postId } from "@lens-protocol/client";import { deletePost } from "@lens-protocol/client/actions";
const result = await deletePost(sessionClient, { post: postId("01234…"),});
if (result.isErr()) { return console.error(result.error);}
- TypeScript
- GraphQL
- React
Finally, handle the result using the adapter for the library of your choice:
See the Transaction Lifecycle guide for more information on how to determine the status of the transaction.
Finally, to delete a Post's content, you must remove the Post Metadata object located at post.contentURI, along with any referenced files.
The deletion process depends on the hosting solution used when the Post was created or last updated. For example, if IPFS was used, you should unpin the content to free up resources.
If you used Lens Storage Nodes, the result of the first step will determine your next steps:
If you received a DeletePostResponse, the Lens API has already handled the content deletion for you, and no further action is required.
If you received a SponsoredTransactionRequest or SelfFundedTransactionRequest, you will need to delete the content by calling the lens storage nodes. See the Deleting Content guide for more information.