@headband/cli
v0.1.0
Published
CLI tool for setting up Headband search in any project
Maintainers
Readme
@headband/cli
Interactive CLI for setting up Headband search in any project.
Usage
npx @headband/cli initThis will:
- Ask for your Headband URL (default:
https://headband.dev) - Ask for your search API key (
hb_src_...orhb_adm_...) - Ask for your default search index (e.g.
products,movies) - Detect your package manager (npm, pnpm, yarn, or bun)
- Install
@headband/react - Create
headband.config.tswith your settings - Create an example
<HeadbandSearch />component
Options
npx @headband/cli init --yes # Skip prompts, use defaults
npx @headband/cli --help # Show helpWhat gets created
headband.config.ts -- Search configuration that reads from NEXT_PUBLIC_HEADBAND_KEY env var with a fallback:
export const headbandConfig = {
url: "https://headband.dev",
searchKey: process.env.NEXT_PUBLIC_HEADBAND_KEY || "hb_src_...",
defaultIndex: "products",
};components/headband-search.tsx (or src/components/ if your project uses a src/ directory) -- A ready-to-use search component:
"use client";
import {
headband,
HeadbandProvider,
SearchBox,
Hits,
Stats,
} from "@headband/react";
import { headbandConfig } from "../headband.config";
const client = headband(headbandConfig.url, headbandConfig.searchKey);
export function HeadbandSearch() {
return (
<HeadbandProvider client={client} index={headbandConfig.defaultIndex}>
<SearchBox placeholder={`Search products...`} />
<Stats />
<Hits />
</HeadbandProvider>
);
}License
MIT
