Skip to content
thefaqappthefaqapp
Browse docs

Next.js App Router

Render thefaqapp content in a Next.js 15+ app with server components, revalidation, and client-side search.

Updated 2026-10-11

The most common integration: a Next.js app rendering FAQ content on a public marketing or help surface.

bun add @faqapp/core @faqapp/react

Server-side render a list

import { createFAQClient } from "@faqapp/core";

export const revalidate = 300;

const faq = createFAQClient({
  apiKey: process.env.FAQAPP_API_KEY,
  organizationSlug: "acme"
});

export default async function HelpPage() {
  const { data: questions } = await faq.questions.list({ status: "published", limit: 50 });

  return (
    <main>
      <h1>Help</h1>
      {questions.map(question => (
        <article key={question.id}>
          <h2>{question.question}</h2>
          <p>{question.answer}</p>
        </article>
      ))}
    </main>
  );
}

Save this as app/help/page.tsx. revalidate = 300 refreshes the page every five minutes. FAQAPP_API_KEY is a server key with read scope. It stays server-side: never prefix it with NEXT_PUBLIC_.

Per-question dynamic route

import { createFAQClient, FAQNotFoundError } from "@faqapp/core";
import { notFound } from "next/navigation";

const faq = createFAQClient({
  apiKey: process.env.FAQAPP_API_KEY,
  organizationSlug: "acme"
});

export async function generateStaticParams() {
  const { data } = await faq.questions.list({ status: "published", limit: 100 });
  return data.map(question => ({ slug: question.slug }));
}

export default async function QuestionPage({ params }: { params: Promise<{ slug: string }> }) {
  const { slug } = await params;
  try {
    const { data: question } = await faq.questions.get(slug);
    return (
      <article>
        <h1>{question.question}</h1>
        <p>{question.answer}</p>
      </article>
    );
  } catch (err) {
    if (err instanceof FAQNotFoundError) notFound();
    throw err;
  }
}

Save this as app/help/[slug]/page.tsx. Next.js 15 passes params as a promise.

Client-side hooks for interactive surfaces

For client-side search as the reader types:

"use client";
import { createFAQClient, FAQClientProvider, useSearch } from "@faqapp/react";
import { useState } from "react";

const faq = createFAQClient({
  apiKey: process.env.NEXT_PUBLIC_FAQAPP_PUBLISHABLE_KEY,
  organizationSlug: "acme"
});

export function SearchableList() {
  return (
    <FAQClientProvider client={faq}>
      <Inner />
    </FAQClientProvider>
  );
}

function Inner() {
  const [query, setQuery] = useState("");
  const { results } = useSearch(query);
  return (
    <div>
      <input value={query} onChange={event => setQuery(event.target.value)} />
      {results?.results.map(result => (
        <article key={result.id}>
          <h3>{result.question}</h3>
          <p>{result.answer}</p>
        </article>
      ))}
    </div>
  );
}

Save this as app/help/SearchableList.tsx. A client component ships its key to every visitor, so use a publishable key here. It reads published FAQs and search only. A read key is not safe in the browser: it reads drafts and private product facts. Keep server keys in variables without the NEXT_PUBLIC_ prefix.

Revalidate on publish

Point a webhook at a Route Handler that verifies the signature, then calls revalidatePath. verifyFaqappWebhook is the function from the webhooks guide; copy it into lib/verify-faqapp-webhook.ts.

import { revalidatePath } from "next/cache";
import { verifyFaqappWebhook } from "@/lib/verify-faqapp-webhook";

export async function POST(request: Request) {
  const raw = await request.text();
  const signature = request.headers.get("X-Faqapp-Webhook-Signature") ?? "";
  if (!verifyFaqappWebhook([process.env.FAQAPP_WEBHOOK_SECRET ?? ""], raw, signature)) {
    return new Response("invalid signature", { status: 401 });
  }

  const delivery = JSON.parse(raw) as { event: string; data: { slug?: string } };
  if (delivery.event === "question.published" || delivery.event === "question.updated") {
    revalidatePath("/help");
    if (delivery.data.slug) revalidatePath(`/help/${delivery.data.slug}`);
  }
  return new Response(null, { status: 204 });
}

Save this as app/api/faqapp-webhook/route.ts. Add the webhook URL in the dashboard under Settings, then Webhooks. Store the signing secret as FAQAPP_WEBHOOK_SECRET.