Skip to content
Reponse.ai LogoDocs
DocsAPISDKsGuides

Search Documentation

Search for an article...

Getting Started

  • Overview
  • Architecture
  • Installation
  • Authentication
  • First Request

Products & Collections

  • Products — List
  • Products — Get
  • Products — Metafields
  • Collections — List
  • Collections — Get
  • Collections — Products

Cart & Checkout

  • Cart — Create
  • Cart — Get
  • Cart — Add Item
  • Cart — Update Item
  • Cart — Remove Item
  • Cart — Apply Promotion
  • Checkout — Stripe
  • Checkout — Payment Intent
  • Checkout — ACP

Orders & Fulfillment

  • Orders — Create
  • Orders — Get
  • Orders — Confirm
  • Orders — Cancel
  • Orders — Fulfill
  • Orders — Refund

Commerce

  • Inventory — Get
  • Inventory — Update
  • Shipping — Rates
  • Discounts — List
  • Discounts — Create
  • Discounts — Validate
  • Subscriptions — Manage

Loyalty & Gift Cards

  • Loyalty — Balance
  • Loyalty — Redeem
  • Loyalty — Referral
  • Gift Cards — List
  • Gift Cards — Redeem

Tickets & Support

  • Tickets — List
  • Tickets — Create
  • Tickets — Reply

Platform

  • Product Feed — JSON
  • Product Feed — CSV
  • Theme — Get
  • Approvals — Execute
  • Approvals — Reject
  • Geocode

SDKs

  • SDK Overview
  • TypeScript SDK
  • React Hooks

Guides

  • Chat Widget
  • Shopify Sync
  • Storefront Starter
  • Loyalty Program
  • Discounts & Promotions
  • Subscriptions
  • Klaviyo Integration
  • Custom Domains
  • Agentic Commerce (ACP)
  • A2A Protocol
  • AI Engines
  • MCP Server

Webhooks

  • Webhooks Overview
  • Events Reference
  • Shopify Webhooks
  • Stripe Webhooks
  • Reviews (Stamped / Trustpilot)
  • Logistics
  • Email Inbound

Resources

  • Environment Variables
  • Rate Limits
  • Changelog
DocsSDKsReact Hooks

React Hooks

React hooks for data fetching with SWR.

1 min read/Last updated Jul 22, 2026
On this page

Overview

`@reponseai/react` provides SWR-powered hooks for declarative data fetching with automatic caching, revalidation, and error handling. Wrap your app in `ReponseProvider`, then use hooks like `useProducts`, `useProduct`, and `useChat` in any component.

Setup

Install the package:

bash
npm install @reponseai/react

Wrap your application with `ReponseProvider`:

tsx
import { ReponseProvider } from "@reponseai/react";

export default function App({ children }) {
  return (
    <ReponseProvider apiKey="rp_live_..." baseUrl="https://api.reponse.ai">
      {children}
    </ReponseProvider>
  );
}

Provider Props

PropTypeRequiredDescription
apiKeystringYesYour workspace API key.
baseUrlstringNoOverride the default API URL.
swrConfigSWRConfigurationNoGlobal SWR options (dedupingInterval, etc.).

useProducts

Fetch a paginated list of products.

tsx
import { useProducts } from "@reponseai/react";

function ProductGrid() {
  const { data, error, isLoading, mutate } = useProducts({
    limit: 20,
    offset: 0,
    query: "sneaker",
  });

  if (isLoading) return <p>Loading…</p>;
  if (error) return <p>Error: {error.message}</p>;

  return (
    <ul>
      {data.map((product) => (
        <li key={product.id}>{product.title} — ${product.variants[0]?.price}</li>
      ))}
    </ul>
  );
}
ParameterTypeDefaultDescription
limitnumber20Number of products per page.
offsetnumber0Pagination offset.
querystring—Free-text search filter.

useProduct

Fetch a single product by ID.

tsx
import { useProduct } from "@reponseai/react";

function ProductDetail({ productId }: { productId: string }) {
  const { data: product, error, isLoading } = useProduct(productId);

  if (isLoading) return <p>Loading…</p>;
  if (error) return <p>Product not found</p>;

  return (
    <div>
      <h1>{product.title}</h1>
      <p>{product.description}</p>
    </div>
  );
}

useChat

Manage a chat conversation with the AI engine.

tsx
import { useChat } from "@reponseai/react";

function ChatPanel({ campaignId }: { campaignId: string }) {
  const { messages, sendMessage, isStreaming, error } = useChat({
    campaignId,
  });

  const handleSend = (text: string) => {
    sendMessage(text);
  };

  return (
    <div>
      {messages.map((msg, i) => (
        <p key={i} className={msg.role}>
          {msg.content}
        </p>
      ))}
      {isStreaming && <p>Typing…</p>}
    </div>
  );
}
ParameterTypeRequiredDescription
campaignIdstringYesThe campaign to chat with.
conversationIdstringNoResume an existing conversation.
utmParamsRecordNoUTM params for engine dispatch.

useCart

Manage cart state synced with the Reponse backend.

tsx
import { useCart } from "@reponseai/react";

function CartButton({ variantId }: { variantId: string }) {
  const { addItem, cart, isUpdating } = useCart();

  return (
    <button onClick={() => addItem(variantId, 1)} disabled={isUpdating}>
      Add to cart ({cart?.items.length ?? 0})
    </button>
  );
}

Hooks Reference

HookReturnsDescription
useProducts(opts){ data, error, isLoading, mutate }Paginated product list.
useProduct(id){ data, error, isLoading }Single product by ID.
useChat(opts){ messages, sendMessage, isStreaming, error }Chat conversation.
useCart(){ cart, addItem, removeItem, isUpdating }Cart management.

Troubleshooting

IssueSolution
useProducts returns undefinedEnsure the component is inside ReponseProvider.
Stale data after mutationCall mutate() to revalidate or pass revalidateOnFocus: true.
401 errors in the browserNever use rp_live_ keys client-side. Proxy through your backend or use rp_test_ keys.
TypeScript errors on hook return typesUpdate @reponseai/react to the latest version.
PreviousTypeScript SDK
NextChat Widget