Skip to main content

useArticles

Public knowledge-base list. Reads from the library provider — no auth, safe to render anywhere in your app. Pair with useArticle when you need a single article's content.

Usage

HelpCenter.tsx
import { useArticles } from '@cstar.help/react';

export function HelpCenter() {
  const { articles, isLoading, error, refetch } = useArticles({
    categorySlug: 'billing',
    limit: 10
  });

  if (isLoading) return <p>Loading...</p>;
  if (error) return <p>Couldn't load — try again?</p>;

  return (
    <ul>
      {articles.map((a) => (
        <li key={a.id}>
          <a href={`/help/${a.slug}`}>{a.title}</a>
        </li>
      ))}
    </ul>
  );
}

useArticle

ArticlePage.tsx
import { useArticle } from '@cstar.help/react';

export function ArticlePage({ slug }) {
  const { article, isLoading, error } = useArticle(slug);

  if (isLoading) return <p>Loading...</p>;
  if (error || !article) return <p>Not found</p>;

  return (
    <article>
      <h1>{article.title}</h1>
      <div dangerouslySetInnerHTML={{ __html: article.contentHtml }} />
    </article>
  );
}

Next up