atomicsolutions.dev
Menu

API Reference

Hooks

usePosts(params?)

Fetches a list of WordPress posts.

Parameters: WPPostsParams — any query parameters accepted by GET /wp/v2/posts (e.g. per_page, categories, search).

Returns: UseQueryResult<PaginatedResponse<WPPost>>.

usePost(id)

Fetches a single WordPress post by ID.

Parameters: id: number.

Returns: UseQueryResult<WPPost>.

useInfinitePosts(params?)

Fetches posts with infinite scroll support.

Returns: UseInfiniteQueryResult<PaginatedResponse<WPPost>>. Call fetchNextPage() to load more.

useWPAuth()

Returns the current authentication state: { user, token, isAuthenticated }.

useWPLogin()

Returns a mutation to log in: mutate({ username, password }). On success, stores the JWT token and updates auth state.

useWPLogout()

Returns a mutation to log out and clear the stored token.