Overview
TheuseArticle hook fetches a single news article from the Sui blockchain registry using its Walrus blob ID. It retrieves the full article content from Walrus storage and includes current engagement data (tips and comments).
Function Signature
Parameters
The Walrus blob ID of the article to fetch. This is a unique identifier for the article stored in Walrus.
Return Type
Returns a React QueryUseQueryResult object containing:
The complete article object with full content and engagement data, or
null if the article failed to loadUnique identifier for the article (same as blob_id)
Walrus blob ID containing the article content
Article title
Article category (currently defaults to ‘General’)
Source where the article originated
Unix timestamp when the article was published
Full article content fetched from Walrus
Article summary or excerpt
Original article URL if available
Article cover image URL
Article author name
Total amount of tips received in SUI tokens
Number of individual tips received
Total number of comments on the article
Whether the query is currently loading
Error object if the query failed
Function to manually refetch the article data
Usage
Query Configuration
The hook is configured with the following React Query options:- Query Key:
['article', blobId] - Enabled: Only when
blobIdis provided (truthy) - Caching: Automatically cached by React Query based on the blob ID
The query will not execute if
blobId is an empty string or undefined. This prevents unnecessary API calls.Error Handling
If the article fails to fetch (e.g., invalid blob ID or Walrus error), the hook returnsnull for the data field and logs the error to the console.
Combining with Comments
TheuseArticle hook works seamlessly with comment hooks:
Engagement Data Updates
Engagement data (tips and comment count) is fetched fresh each time the query runs. To see updated engagement:Performance Considerations
- The hook fetches both blockchain data (engagement) and Walrus data (content) in a single query
- Data is automatically cached by React Query based on the blob ID
- Subsequent renders with the same blob ID will use cached data
- Failed fetches return
nullinstead of throwing, allowing graceful error handling
See Also
- useLatestNews - Fetch multiple latest articles
- useArticleComments - Fetch comments for an article
- NewsArticle Type - Full type definition
- Walrus Storage - Understanding Walrus blob storage
