atomicsolutions.dev

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 caching
  • useCart, useAddToCart, useUpdateCartItem, useRemoveCartItem — full cart management
  • useCheckout, usePlaceOrder — checkout flow and order submission
  • useOrders, useOrder — order history for authenticated users
  • Built-in event system: fires add_to_cart, begin_checkout, purchase events — wire to GA4, GTM, or any analytics provider
  • Dual provider architecture: separate StoreProvider (public) and AdminProvider (authenticated)
Need help shipping this in production?

Atomic Solutions builds headless WooCommerce storefronts for clients. Get in touch →