React Hooks for WooCommerce
React Query hooks for headless WooCommerce — cart, checkout, orders, products, and analytics events.
Install
pnpm add @atomic-solutions/react-woocommerce Add to cart with one hook
import { WooCommerceProvider, useCart, useAddToCart } from '@atomic-solutions/react-woocommerce'
function ProductPage({ productId }: { productId: number }) {
const { data: cart } = useCart()
const addToCart = useAddToCart()
return (
<button
onClick={() => addToCart.mutate({ id: productId, quantity: 1 })}
disabled={addToCart.isPending}
>
Add to cart ({cart?.items_count ?? 0} in cart)
</button>
)
} What's included
useProducts,useProduct— product listing and detail with React Query cachinguseCart,useAddToCart,useUpdateCartItem,useRemoveCartItem— full cart managementuseCheckout,usePlaceOrder— checkout flow and order submissionuseOrders,useOrder— order history for authenticated users- Built-in event system: fires
add_to_cart,begin_checkout,purchaseevents — wire to GA4, GTM, or any analytics provider - Dual provider architecture: separate
StoreProvider(public) andAdminProvider(authenticated)
Need help shipping this in production?
Atomic Solutions builds headless WooCommerce storefronts for clients. Get in touch →