Hide Publication
Learn how to hide Lens Publications.
Lens Publications, secured by blockchain technology, are permanent and cannot be deleted. However, a profile has the ability to:
Hide their own publications
Hide comments made by others on their publications
Hide Own Publications
The Lens API allows an authenticated Profile to hide their own publications.
When a publication is hidden, it is flagged in the Lens API database, which prevents it from appearing in feed queries. However, the publication can still be directly accessed via its ID, enabling apps to create redirects or 404 pages as necessary. It's important to note that while the publication's ID is accessible, the actual Publication Metadata will be null.
To hide a publication, you must be authenticated with the Profile of the publication's author. Refer to Profile Login for more details.
- React SDK
- JavaScript SDK
- API
The useHidePublication hook enables you to hide a publication.
Available in @lens-protocol/react-web and @lens-protocol/react-native
import { AnyPublication, useHidePublication } from '@lens-protocol/react-web';
function HidePublicationButton({ publication }: { publication: AnyPublication }) { const { execute: hide, loading } = useHidePublication();
if (publication.isHidden) return <p>Publication is hidden</p>;
return ( <button onClick={() => hide({ publication })} disabled={loading}> Hide </button> );}
That's it—you've successfully hidden a publication!
Hide Other's Comments
The Lens API enables an authenticated Profile to manage other's comments on their publications.
This is an opt-in, off-chain feature. Its user experience varies depending on the specific Lens app used by your audience. Apps aiming to offer a more curated experience for content creators should explicitly enable this feature.
To hide a Comment on a publication, you must be authenticated as the author of the publication. For more details, refer to Profile Login.
Hide Comments
- React SDK
- JavaScript SDK
- API
The useHideCommentToggle hook allows you to hide a Comment. If the Comment is already hidden, using this hook will unhide it.
Available in @lens-protocol/react-web and @lens-protocol/react-native
import { Comment, useHideCommentToggle } from '@lens-protocol/react-web';
function HideableComment({ comment }: { comment: Comment }) { const { execute: toggle, loading } = useHideCommentToggle();
return ( <button onClick={() => toggle({ comment })} disabled={loading}> {comment.hiddenByAuthor ? 'Unhide' : 'Hide'} </button> );}
You can determine whether a Comment has been hidden by the author by using the comment.hiddenByAuthor property.
When retrieving Comments on a publication you can control how hidden comments are included in the results. This also have effects on Publication stats and Profile stats counts.
- React SDK
- JavaScript SDK
- API
Use the request.where.commentOn.hiddenComments property to control the visibility of hidden comments in the query results.
Available in @lens-protocol/react-web and @lens-protocol/react-native
import { usePublications, HiddenCommentsType } from '@lens-protocol/react-web';
// ...
const { data, loading, error } = usePublications({ where: { commentOn: { id: publicationId("0x32-0x4e"), hiddenComments: HiddenCommentsType.Hide, }, },});
The HiddenCommentsType enum has the following options:
HiddenCommentsType.Show: Include hidden comments in the query results.
HiddenCommentsType.Hide: Exclude hidden comments from the query results.
HiddenCommentsType.HiddenOnly: Include only hidden comments in the query results. Use this option to power a 'Hidden Comments' section in your app.