Skip to main content

Function: usePreprint()

usePreprint(uri, options): UseQueryResult<any, Error>

Defined in: web/lib/hooks/use-preprint.ts:75

Fetches a single preprint by AT Protocol URI.

Parameters

uri

string

AT Protocol URI of the preprint

options

UsePreprintOptions = {}

Query options

Returns

UseQueryResult<any, Error>

Query result with preprint data, loading state, and error

Remarks

Uses TanStack Query with a 5-minute stale time since preprints rarely change. Returns cached data while revalidating in background.

Example

const { data: preprint, isLoading, error } = usePreprint(
'at://did:plc:abc/pub.chive.preprint.submission/123'
);

if (isLoading) return <PreprintSkeleton />;
if (error) return <PreprintError error={error} />;

return <PreprintDetail preprint={preprint} />;

Throws

When the preprint API request fails