@faqapp/react
v1.0.0
Published
Official React hooks + SSR helpers for TheFAQApp — wraps @faqapp/core
Maintainers
Readme
@faqapp/react
Official React hooks + SSR helpers for TheFAQApp.
Built on @faqapp/core. Works in any React renderer — Next.js, TanStack Start, Vite, Remix, plain CRA.
Install
bun add @faqapp/reactQuickstart
import { createFAQClient, FAQClientProvider, useFaq } from "@faqapp/react";
const client = createFAQClient({
organizationSlug: "your-org",
apiKey: process.env.NEXT_PUBLIC_FAQAPP_KEY
});
function App() {
return (
<FAQClientProvider client={client}>
<FaqList />
</FAQClientProvider>
);
}
function FaqList() {
const { data, loading, error } = useFaq({ limit: 10 });
if (loading) return <p>Loading…</p>;
if (error) return <p>Error: {error.message}</p>;
return (
<ul>
{data?.map((q: any) => (
<li key={q.id}>
<strong>{q.question}</strong>
<p>{q.answer}</p>
</li>
))}
</ul>
);
}Hooks
| Hook | Purpose |
|------|---------|
| useFaq(params?) | Fetch a list of questions. Cancels on unmount. Refetch via refetch(). |
| useQuestion(slug) | Fetch one question by slug. Null slug = no-op. |
| useSearch(query, opts?) | Debounced search (250ms default). Aborts in-flight requests on every keystroke. |
Why @faqapp/react and not @faqapp/nextjs?
Framework-agnostic. The same package works in Next.js, TanStack Start, Vite SPAs, Remix, etc. For a thin Next.js helper layer (server-component fetch helpers + RSC streaming) install @faqapp/next on top.
License
MIT.
