Skip to content
thefaqappthefaqapp
Browse docs

@faqapp/react

Client-side React hooks for search, published FAQs, and questions. Built on @faqapp/core.

Updated 2026-10-11

bun add @faqapp/react @faqapp/core

@faqapp/react adds a provider and four hooks on top of @faqapp/core. The hooks fetch in the browser after mount, in any React 18 or 19 app.

Provider

Create one client and wrap your tree:

import { createFAQClient, FAQClientProvider } from "@faqapp/react";
import type { ReactNode } from "react";

const faq = createFAQClient({
  apiKey: import.meta.env.VITE_FAQAPP_PUBLISHABLE_KEY,
  organizationSlug: "acme"
});

export function App({ children }: { children: ReactNode }) {
  return <FAQClientProvider client={faq}>{children}</FAQClientProvider>;
}

FAQClientProvider takes two props: client and children. In browser code, use a publishable key. It reads published FAQs and search only, so nothing private can leak. Never ship a read key to the browser; it reads drafts.

Hooks

Hook Request Key it needs
useSearch(query, options?) GET /search Publishable
usePublishedFaqs(params?) GET /faqs Publishable
useFaq(params?) GET /questions Server
useQuestion(slug) GET /questions/:slug Server
import { usePublishedFaqs, useSearch } from "@faqapp/react";
import { useState } from "react";

export function HelpCenter() {
  const [query, setQuery] = useState("");
  const search = useSearch(query);
  const faqs = usePublishedFaqs();

  if (faqs.loading) return <p>Loading…</p>;
  if (faqs.error) return <button type="button" onClick={faqs.refetch}>Retry</button>;

  return (
    <div>
      <input value={query} onChange={event => setQuery(event.target.value)} placeholder="Search the FAQ" />
      <ul>
        {(search.results?.results ?? faqs.data ?? []).map(entry => (
          <li key={entry.slug}>
            <strong>{entry.question}</strong>
            <p>{entry.answer}</p>
          </li>
        ))}
      </ul>
    </div>
  );
}

Every hook returns status, loading, error, and refetch(). useSearch returns results; the others return data. useSearch waits 250 ms after typing stops and sends nothing for queries shorter than 2 characters.

Server rendering

The hooks do not load data on the server. During server rendering they return their first state and send nothing. For server-rendered FAQ content, call @faqapp/core in your loader or server component with a server key, then pass the result down as props. There is no suspense mode, shared cache, or prefetch API.

Migration from @faqapp/nextjs

@faqapp/nextjs is deprecated. Replace its hooks with @faqapp/react, and move server-side fetching to @faqapp/core in a server component or server function.