33 hooks
One hook per documented Blogger API v3 method, plus `useBlogger` for direct client access and `useBloggerQuery`/`useBloggerMutation` for building custom cache-backed hooks.
33 hooks, one per documented Blogger API v3 method. Zod-validated responses at the network boundary, cache with automatic invalidation, and tests that never touch the network.
Install:
npm install react-blogger-apipnpm add react-blogger-apiyarn add react-blogger-apibun add react-blogger-apiWrap your app in BloggerProvider and call a hook:
import { BloggerProvider, usePosts } from 'react-blogger-api'
function App() {
return (
<BloggerProvider config={{ apiKey: 'YOUR_API_KEY', defaultBlogId: '1234567890' }}>
<PostList />
</BloggerProvider>
)
}
function PostList() {
const { items, isLoading, error } = usePosts({ maxResults: 10 })
if (isLoading) return <p>Loading…</p>
if (error) return <p>Failed: {error.message}</p>
return <ul>{items.map((post) => <li key={post.id}>{post.title}</li>)}</ul>
}With defaultBlogId set, every blog-scoped hook resolves the blog automatically. Pass options.blogId per hook to override it.
The standalone client works outside React:
import { createBloggerClient } from 'react-blogger-api'
const client = createBloggerClient({ apiKey: 'YOUR_API_KEY' })
const post = await client.posts.get({ blogId: '1234567890', postId: '42' })apiKey alone.insert / update / patch / delete / publish / revert) and any read of a private blog require accessToken, sent as Authorization: Bearer <token>.accessToken when the token rotates — it is resolved per request.QueryStore works.fetch in unit tests.