Astro Quickstart

Five minutes from clone to working chat in Astro. Install, seed, wire the provider, drop in the library and chat components. Done.

One paste and your AI reads our docs and sets cStar up with you.

1. Install

bash
npm install @cstar.help/js

2. Seed sample data

Empty workspaces aren't fun to test against. Populate yours with realistic content first:

bash
cstar seed

Creates 5 categories, 12 articles, 3 customers, and 5 tickets. Full breakdown over at the quickstart.

3. Wire up the client

src/lib/cstar.js
// Server-side only: Astro frontmatter and endpoints.
import { CStarClient } from '@cstar.help/js';
import { LibraryClient } from '@cstar.help/js/library';

// CSTAR_SECRET_KEY in .env. No PUBLIC_ prefix, so it never reaches the browser.
export const cstar = new CStarClient({
  apiKey: import.meta.env.CSTAR_SECRET_KEY,
  teamId: 'your-team-id'
});

// The public help center needs no key.
// Seeded with a test key (cstar seed)? Add publishableKey: 'pk_test_...' to read test articles.
export const library = new LibraryClient({ teamSlug: 'your-team-slug' });

4. Browse the Knowledge Base

List categories and articles from your public help center.

src/pages/help/index.astro
---
import { library } from '../../lib/cstar.js';

// A static build fetches these once, at build time.
const categories = await library.categories();
const articles = await library.articles({ limit: 5 });
---
<h1>Help Center</h1>
<ul>
  {categories.map((cat) => (
    <li><a href={`/help/${cat.slug}`}>{cat.name}</a> ({cat.article_count})</li>
  ))}
</ul>

<h2>Latest Articles</h2>
<ul>
  {articles.map((a) => <li><a href={`/help/articles/${a.slug}`}>{a.title}</a></li>)}
</ul>

5. Add the Chat Widget

One tag in your layout puts chat on every page. Your team answers from the cStar inbox.

src/layouts/Layout.astro
---
const { title } = Astro.props;
---
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <title>{title}</title>
  </head>
  <body>
    <slot />
    <!-- is:inline keeps Astro from bundling the cStar tag -->
    <script is:inline src="https://www.cstar.help/cstar.js?team=your-team-slug"></script>
  </body>
</html>

Search as the visitor types, right in the browser. Works on a fully static site.

src/components/HelpSearch.astro
<input id="help-search" type="search" placeholder="Search help articles" />
<ul id="help-results"></ul>

<script>
  // Astro bundles this script, so the import works on a static site.
  import { LibraryClient } from '@cstar.help/js/library';

  // Seeded with a test key (cstar seed)? Add publishableKey: 'pk_test_...' to read test articles.
  const library = new LibraryClient({ teamSlug: 'your-team-slug' });
  const input = document.getElementById('help-search') as HTMLInputElement;
  const list = document.getElementById('help-results') as HTMLUListElement;
  let timer: ReturnType<typeof setTimeout>;

  input.addEventListener('input', () => {
    clearTimeout(timer);
    timer = setTimeout(async () => {
      const query = input.value.trim();
      if (!query) return list.replaceChildren();
      const { data } = await library.search(query, { limit: 5 });
      list.replaceChildren(
        ...data.map((article) => {
          const item = document.createElement('li');
          item.textContent = article.title;
          return item;
        })
      );
    }, 300);
  });
</script>

What's Next?