Function: useTrending()
useTrending(
params):UseQueryResult<OutputSchema,Error>
Defined in: web/lib/hooks/use-trending.ts:77
Fetches trending eprints based on view metrics.
Parameters
params
UseTrendingParams = {}
Query parameters (window, limit, cursor, fieldUris)
Returns
UseQueryResult<OutputSchema, Error>
Query result with trending eprints, loading state, and error
Remarks
Uses TanStack Query with a 1-minute stale time for near-real-time updates.
Trending is calculated based on views within the specified time window.
When fieldUris are provided, the API flags entries that match the user's
fields with inUserFields: true and sorts them first.
Example
const { data, isLoading, error } = useTrending({ window: '7d', limit: 10 });
if (isLoading) return <TrendingSkeleton />;
if (error) return <ErrorMessage error={error} />;
return (
<TrendingList>
{data.trending.map((eprint) => (
<TrendingCard key={eprint.uri} eprint={eprint} />
))}
</TrendingList>
);
Throws
When the trending API request fails