UNPKG

@lens-protocol/react

Version:

Interacting with the Lens Protocol API using React.

80 lines (79 loc) 2.2 kB
import { AnyPublication, PublicationsRequest } from '@lens-protocol/api-bindings'; import { PaginatedArgs, PaginatedReadResult } from "../helpers/reads.js"; import { SuspenseEnabled, SuspensePaginatedResult } from "../helpers/suspense.js"; /** * {@link usePublications} hook arguments */ export type UsePublicationsArgs = PaginatedArgs<PublicationsRequest>; export type { PublicationsRequest }; /** * {@link usePublications} hook arguments with Suspense support * * @experimental This API can change without notice */ export type UseSuspensePublicationsArgs = SuspenseEnabled<UsePublicationsArgs>; /** * Retrieves a paginated list of publications, filtered according to specified criteria. * * Fetch by Publication Type: * ```tsx * const { data, loading, error } = usePublications({ * where: { * publicationTypes: [PublicationType.Post], * } * }); * ``` * * Fetch by Main Content Focus: * ```tsx * const { data, loading, error } = usePublications({ * where: { * publicationTypes: [PublicationType.Post] * metadata: { * mainContentFocus: [PublicationMetadataMainFocusType.ShortVideo], * } * } * }); * ``` * * Fetch Post's comments: * ```tsx * const { data, loading, error } = usePublications({ * where: { * commentOn: { * id: publicationId('0x03-0x24'), * }, * } * }); * ``` * * Fetch Profile's Publications: * ```tsx * const { data, loading, error } = usePublications({ * where: { * from: [profileId('0x01')], * } * }); * ``` * * @category Publications * @group Hooks */ export declare function usePublications(args: UsePublicationsArgs): PaginatedReadResult<AnyPublication[]>; /** * Retrieves a paginated list of publications, filtered according to specified criteria. * * This signature supports [React Suspense](https://react.dev/reference/react/Suspense). * * ```tsx * const { data } = usePublications({ * where: { ... }, * suspense: true, * }); * ``` * * @experimental This API can change without notice * @category Publications * @group Hooks */ export declare function usePublications(args: UseSuspensePublicationsArgs): SuspensePaginatedResult<AnyPublication[]>;