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, refresh } = 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';
import DOMPurify from 'dompurify';
import { marked } from 'marked';
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>
{/* Article bodies are Markdown: render, then sanitize before injecting. */}
<div dangerouslySetInnerHTML={{ __html: DOMPurify.sanitize(marked.parse(article.content ?? '', { async: false })) }} />
</article>
);
}