Skip to content

Nuxt connector

bainquet-nuxt is a Nuxt 3+ module (defineNuxtModule) that publishes a site's content to bAInquet. Extraction runs at build time over a content-source adapter registry; delivery rides the canonical @bainquet/connector-sdk. It also serves the site's local discovery files through Nitro server routes.

Stable Signing parity is covered by the SDK's sign.test.ts (this module imports the SDK signer rather than vendoring it).

What it maps

Each adapter yields IngestItem objects via ctx.makeItem, which computes the cross-connector-stable sha256: checksum. Built-in adapters map Nuxt Content docs to the post SourceType (drafts excluded; article is not a SourceType) and the resolved route list to page. Change detection is build-driven: a rebuild reconciles the whole site, unchanged items return skipped, and removed ids (versus the advisory manifest) are tombstoned.

Install

bash
npm install bainquet-nuxt   # peer: @nuxt/kit (provided by your Nuxt app)

Configuration

ts
// nuxt.config.ts
export default defineNuxtConfig({
  modules: ["bainquet-nuxt"],
  bainquet: {
    siteDomain: "acme.com",
    siteOrigin: "https://acme.com",
    defaultLanguage: "en",
    adapters: [
      // see below
    ],
    nodeFiles: { llms: true, llmsFull: true, aiJson: true },
    ingestOnBuild: true,
    deleteRemoved: true,
  },
});

On setup the module:

  1. Merges the bainquet block into private (server-only) runtimeConfig and throws if a token or secret is found under runtimeConfig.public (client-leak guard).
  2. Registers Nitro routes for /llms.txt, /llms-full.txt, and /.well-known/ai.json, and adds them to nitro.prerender.routes so they exist as static files under nuxt generate.
  3. Hooks the postbuild close event to run a sync when ingestOnBuild is set.

WARNING

Secrets live only in private runtimeConfig and env, never in runtimeConfig.public, and never in the client bundle. The setup step throws if it finds a token under the public config.

Secrets (server-side only)

VariablePurpose
BAINQUET_API_URLAPI origin, default https://api.bainquet.online (a trailing /v1 is tolerated and stripped)
BAINQUET_CONNECTOR_TOKENconnectorId.secret
BAINQUET_WEBSITE_IDscoped website id

Mapping pattern

Adding a content source means registering an adapter. Use the built-ins, or define a bespoke one with defineAdapter:

ts
import { nuxtContentAdapter, pagesAdapter, defineAdapter } from "bainquet-nuxt";

// Built-ins:
nuxtContentAdapter((ctx) => queryMyContentDocs(ctx));   // docs -> "post", drafts excluded
pagesAdapter({ exclude: (r) => r.startsWith("/admin") }); // routes -> "page"

// Bespoke:
export const productsAdapter = defineAdapter({
  name: "products",
  sourceType: "product",
  async extract(ctx) {
    const out = [];
    for (const p of await loadProducts()) {
      out.push(ctx.makeItem({
        type: "product",
        id: `product:${p.slug}`,
        url: `${ctx.siteOrigin}/products/${p.slug}`,
        title: p.title,
        html: p.html,
        json: { product: { price: { value: p.price, unit: "currency", currency: p.currency } } }, // typed
      }));
    }
    return out;
  },
});

An adapter has a name, a sourceType (a SourceType), and an extract function that returns items. pagesAdapter consumes the resolved route list rather than re-deriving routing.

Local discovery files

The module registers three Nitro routes that render from the current item set: /llms.txt, /llms-full.txt, and /.well-known/ai.json. They serve dynamically in SSR or hybrid mode and prerender to static files under nuxt generate. Wire src/runtime/server/routes/_items.ts to your build-emitted item cache to serve real content.

These are the site's own local discovery files. The canonical, published Knowledge Node on bainquet.online stays authoritative; see Node files.

Incremental sync

Set ingestOnBuild: true to run a sync on the postbuild close hook. A rebuild reconciles the whole site against the server; unchanged items return skipped, and ids removed since the advisory manifest are tombstoned (deleteRemoved: true).

Backfill

There is no separate backfill command: a full build-time sync reconciles the entire site against the server, which is itself the backfill.

Signing

Signing, retry and backoff, chunking, and idempotency all come from @bainquet/connector-sdk, so the canonical-string and HKDF derivation are identical to every other bAInquet connector. See Ingestion and signing.

Out of scope

  • @nuxt/kit is a peer dependency provided by the host; for standalone typecheck the package uses a thin local shim for the small slice of Nuxt and Nitro types it touches.
  • Deterministic-first: no LLM in the module.

Owner-controlled structured data for AI.