Nuxt module to integrate Aidbase features into your app.
AidbaseChatbot component for embedding the Aidbase chat widget./api/aidbase/faq to fetch mapped FAQ items from Aidbase for a configured knowledge base.ab- prefixed elements as custom elements.Install the module to your Nuxt application with one command:
npx nuxi module add nuxt-aidbase
That's it! You can now use Nuxt Aidbase in your Nuxt app ✨
Add configuration to your nuxt.config under the aidbase key. Example:
export default defineNuxtConfig({
aidbase: {
// ID of the Aidbase FAQ knowledge base to use for `/api/aidbase/faq`
faqKnowledgeId: 'your-faq-knowledge-id',
},
})
Important environment variables:
NUXT_PRIVATE_AIDBASE_API_TOKEN (required) — Your Aidbase API token. The module will log an error at setup if this is not set and the server endpoints that require it will return an error.NUXT_PRIVATE_AIDBASE_FAQ_CACHE_MAX_AGE (optional) — Cache TTL (in seconds) for the FAQ endpoint in production. Defaults to 3600.Security note: The API token must be stored in a private server-only env var (the module reads it via process.env.NUXT_PRIVATE_AIDBASE_API_TOKEN and exposes it to server runtime config only).
AidbaseChatbotThe module auto-registers a component named AidbaseChatbot that you can place anywhere in your application.
Props:
| Prop | Type | Required | Default | Description |
|---|---|---|---|---|
id | string | yes | - | The Aidbase chatbot ID (from your Aidbase dashboard). |
theme | 'light' | 'dark' | no | 'light' | Chat widget theme. |
classes | string | no | 'fixed p-4 bottom-0 right-0 z-[99]' | Additional CSS classes for the widget container. |
styles | CSSStyleValue | no | - | Inline styles for the widget container. |
Example:
<template>
<AidbaseChatbot id="my-chatbot-id" theme="dark"></AidbaseChatbot>
</template>
Notes:
https://client.aidbase.ai/chat.ab.js) and will add a small helper script to set the chatbot id on SPA navigation.ab- are treated as custom elements (no warnings).This module exposes a server handler at /api/aidbase/faq that fetches FAQ items from the Aidbase API for a configured knowledge base and returns a simplified array of items with question and answer fields.
Behavior:
NUXT_PRIVATE_AIDBASE_API_TOKEN (env var) — mandatoryruntimeConfig.public.aidbase.faqKnowledgeId (module option / nuxt config)https://api.aidbase.ai/v1/knowledge/{faqKnowledgeId}/faq-items{ question: string, answer: string } where answer is a markdown string assembled from the Aidbase response.cachedEventHandler. Default cache age:
NUXT_PRIVATE_AIDBASE_FAQ_CACHE_MAX_AGE (seconds) or fallback to 3600 (1 hour)Example response:
[
{
"question": "How do I reset my password?",
"answer": "You can reset your password by..."
},
{
"question": "Is there a free tier?",
"answer": "Yes — the free tier includes..."
}
]
Errors:
Aidbase API token is not configured.Aidbase FAQ knowledge ID is not configured.# Install dependencies
npm install
# Generate type stubs
npm run dev:prepare
# Develop with the playground
npm run dev
# Build the playground
npm run dev:build
# Run ESLint
npm run lint
# Run Vitest
npm run test
npm run test:watch
# Release new version
npm run release