Overview
TheuseLatestNews hook fetches the latest news articles from the Sui blockchain registry and retrieves their full content from Walrus storage. It automatically includes engagement data (tips and comments) for each article.
Function Signature
Parameters
Maximum number of articles to fetch. Articles are returned in reverse chronological order (newest first).
Return Type
Returns a React QueryUseQueryResult object containing:
Array of news articles with full content and engagement data
Unique identifier for the article (same as blob_id)
Walrus blob ID containing the article content
Article title
Article category (currently defaults to ‘General’)
Source of the article
Unix timestamp when the article was published
Full article content fetched from Walrus
Article summary or excerpt
Original article URL
Article cover image URL
Article author name
Total tips received in SUI tokens
Number of tips received
Number of comments on the article
Whether the query is currently loading
Error object if the query failed
Function to manually refetch the articles
Usage
Query Configuration
The hook is configured with the following React Query options:- Query Key:
['latestNews', limit] - Stale Time: 30 seconds (data is considered fresh for 30 seconds)
- Caching: Automatically cached by React Query based on the limit parameter
The hook fetches articles in batches and retrieves full content from Walrus for each article. This may take a few seconds for large limit values.
Error Handling
If individual articles fail to fetch, they are filtered out of the results. The hook will return all successfully fetched articles rather than failing completely.See Also
- useArticle - Fetch a single article by ID
- useArticleComments - Fetch comments for an article
- NewsArticle Type - Full type definition
