Lens Blocks are currently in pre-alpha and not ready for use!

Use Post Context Hook

A hook for queries and operations in a shared Lens post context

This hook exposes the Post context from LensPostProvider allowing access to the post data and related functionalities within the context of a Lens Post. It is useful for components that need to interact with or display information about a specific Post.

Installation

Usage

This hook can only be used in components that are children of a LensPostProvider.

import { useLensPostContext } from "@/hooks/use-lens-post-context";
const { post } = useLensPostContext();

API Reference

The return value of the hook is a PostContextType object:

PropDescriptionType
postThe Post data object.AnyPost
loadingA boolean indicating if the post data is currently being loaded.boolean
errorAn error object if there was an issue fetching the post data.Error
optimisticThe local state of Post actions.OptimisticState
toggleLikeToggle the upvote status for the authenticated user.function
commentCreate a comment on the Post from the authenticated user.function
collectCollect the Post for the authenticated user.function
repostRepost the post by the authenticated user.function
quoteQuote the post by the authenticated user.function
tipTip the post from the authenticated user.function
toggleBookmarkToggle the bookmark status for the authenticated user.function