@speak2web/create-chat
v1.0.0
Published
Scaffold a pre-wired Speak2Web AIN/AIC chat app (Next.js App Router or Vite/React) against your headless bridge. `npm create @speak2web/chat`.
Readme
@speak2web/create-chat
Scaffold a pre-wired Speak2Web AIN/AIC chat app against your headless bridge — so day-one is
a working app, not hand-wiring createClient + provider + widget + env vars (SPEAK-234).
npm create @speak2web/chat my-app
# or
npx @speak2web/create-chat my-appInteractive by default — it prompts for the template and your bridge values, then writes them to the project's env file. Or pass flags for a non-interactive run:
npx @speak2web/create-chat my-app \
--template next-app \
--api-base https://your-site.com/wp-json/s2w/v1 \
--site-id pub_abc123 \
--yesOptions
| Flag | Description |
|---|---|
| <project-name> | Positional. Directory to create (must not exist). |
| -t, --template | next-app (default) or vite-react. |
| --api-base | Bridge REST base, e.g. https://site.com/wp-json/s2w/v1. |
| --token-endpoint | JWT issuer. Defaults to <api-base>/auth/jwt. |
| --site-id | Public site id from AI-Gateway → Headless / JWT (pub_…). |
| -y, --yes | Skip prompts; use flags/defaults (also auto-on when there's no TTY). |
| -h, --help | Show help. |
Templates
| Template | Stack | Source | Env file / prefix |
|---|---|---|---|
| next-app | Next.js (App Router) | ecis2-next-pilot | .env.local / NEXT_PUBLIC_S2W_* |
| vite-react | Vite + plain React | bridge-harness | .env / VITE_S2W_* |
Both mount createClient() → <AICChatProvider> → <AICChat> (the wiring in
ecis2-next-pilot/app/chat-widget.tsx).
After scaffolding
cd my-app
npm install
npm run dev # http://localhost:5173Then make sure the app's origin is allowlisted in AI-Gateway → Headless / JWT → Allowed
origins (e.g. http://localhost:5173), or the token mint (/auth/jwt) returns 403.
SDK dependency (SPEAK-230)
Generated apps depend on @speak2web/ain-aic-sdk. Until it's published to npm (SPEAK-230),
npm install can't resolve it from the registry — link a local build instead:
# in the SDK repo
npm run build && npm link
# in the generated app
npm link @speak2web/ain-aic-sdkZero runtime dependencies — Node 18+ built-ins only.
