Vue / Nuxt Quickstart

Five minutes from clone to working chat in Vue / Nuxt. 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

server/utils/cstar.ts
// server/utils/cstar.ts: auto-imported in server routes, never sent to the browser.
import { CStarClient } from '@cstar.help/js';

export function useCStar() {
  // runtimeConfig.cstarSecretKey, set by NUXT_CSTAR_SECRET_KEY in .env
  const { cstarSecretKey } = useRuntimeConfig();
  return new CStarClient({ apiKey: cstarSecretKey, teamId: 'your-team-id' });
}

4. Browse the Knowledge Base

List categories and articles from your public help center.

pages/help/index.vue
<script setup lang="ts">
import { LibraryClient } from '@cstar.help/js/library';

// The public help center needs no key.
// Seeded with a test key (cstar seed)? Add publishableKey: 'pk_test_...' to read test articles.
const library = new LibraryClient({ teamSlug: 'your-team-slug' });
const { data } = await useAsyncData('help-center', async () => ({
  categories: await library.categories(),
  articles: await library.articles({ limit: 5 })
}));
</script>

<template>
  <h1>Help Center</h1>
  <ul>
    <li v-for="cat in data?.categories" :key="cat.id">
      <NuxtLink :to="`/help/${cat.slug}`">{{ cat.name }}</NuxtLink> ({{ cat.article_count }})
    </li>
  </ul>

  <h2>Latest Articles</h2>
  <ul>
    <li v-for="a in data?.articles" :key="a.id">
      <NuxtLink :to="`/help/articles/${a.slug}`">{{ a.title }}</NuxtLink>
    </li>
  </ul>
</template>

5. Add the Chat Widget

One script in your Nuxt config puts chat on every page. Your team answers from the cStar inbox.

nuxt.config.ts
// nuxt.config.ts
export default defineNuxtConfig({
  runtimeConfig: {
    cstarSecretKey: '' // server only: NUXT_CSTAR_SECRET_KEY in .env
  },
  app: {
    head: {
      // The chat widget on every page, before the closing </body>.
      script: [
        { src: 'https://www.cstar.help/cstar.js?team=your-team-slug', tagPosition: 'bodyClose' }
      ]
    }
  }
});

Search as the visitor types. No server round trip, no key in the browser.

components/HelpSearch.vue
<script setup lang="ts">
import { LibraryClient, type LibraryArticle } 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 query = ref('');
const results = ref<LibraryArticle[]>([]);
let timer: ReturnType<typeof setTimeout>;

watch(query, (value) => {
  clearTimeout(timer);
  timer = setTimeout(async () => {
    const q = value.trim();
    results.value = q ? (await library.search(q, { limit: 5 })).data : [];
  }, 300);
});
</script>

<template>
  <input v-model="query" type="search" placeholder="Search help articles" />
  <ul>
    <li v-for="hit in results" :key="hit.id">{{ hit.title }}</li>
  </ul>
</template>

What's Next?