React Hooks for WordPress
React Query hooks for the WordPress REST API — works in React web and React Native.
Install
pnpm add @atomic-solutions/react-wordpress Fetch posts with one hook
import { WordPressProvider, usePosts } from '@atomic-solutions/react-wordpress'
function App() {
return (
<WordPressProvider baseURL="https://your-site.com/wp-json">
<BlogList />
</WordPressProvider>
)
}
function BlogList() {
const { data, isLoading } = usePosts({ per_page: 10 })
if (isLoading) return <div>Loading…</div>
return (
<ul>
{data?.data.map(post => (
<li key={post.id}>{post.title.rendered}</li>
))}
</ul>
)
} What's included
usePosts,usePost,usePages,usePage— fetch content with automatic React Query cachinguseInfinitePosts— infinite scroll withfetchNextPageuseWPAuth,useWPLogin,useWPLogout— JWT authentication flow- Works in React 18+, React Native, and Expo
- Full TypeScript — all response shapes are typed via Zod schemas
Compared to alternatives
- vs @wordpress/api-fetch: No React Query integration, no caching, no hooks. You'd wire all that yourself.
- vs Faust.js: Framework-level lock-in, GraphQL-only. This package works with the standard REST API and doesn't dictate your routing or build setup.
- vs wp-graphql + urql/apollo: REST, not GraphQL. Simpler server setup, no schema stitching required.
Need help shipping this in production?
Atomic Solutions builds headless WordPress storefronts for clients. Get in touch →