Skip to main content
A lean, embeddable statute-search chat built on Next.js 15, TypeScript, and Tailwind CSS. It proxies questions to the Vaquill statutes API, streams matches word-by-word, and renders structured statute sources with section titles, citations, code and title details, excerpts, and source links. Every request is pinned to countryCode: "US" server-side so it is the right pick for US-only deployments. Source: github.com/Vaquill-AI/integrations/widget-next.

What you get

  • Next.js 15 App Router with standalone build output
  • Word-by-word streaming animation over SSE
  • Inline [N] citation links that anchor to the matching source card
  • Structured statute source cards: section title, citation, code, title, jurisdiction, excerpt, relevance score
  • Per-source link priority: Vaquill-hosted statute URLs, then govinfo.gov
  • Standard vs Deep search mode toggle
  • Light and dark themes via CSS custom properties
  • CORS headers pre-configured for iframe embedding
  • Single env var to deploy

Prerequisites

Quickstart

1

Clone and install

2

Add your API key

Open .env.local and set:
3

Run the dev server

Open http://localhost:3000 and ask a test question.

Configuration

The API key is the only secret. Everything else is hardcoded in src/config/constants.ts so embedders edit one file and redeploy.

Environment variables

In-code configuration

Open src/config/constants.ts:
countryCode: "US" is enforced server-side in the API route, so even a forked client cannot accidentally widen the jurisdiction.

API routes

The Next.js app exposes two serverless routes that proxy the Vaquill API: Example request body:
See the full schema in the Statutes Search API reference.

Embedding

The widget can be embedded on any page via an <iframe>:

Deployment

1

Install the CLI

2

Deploy

3

Set the API key

In the Vercel dashboard, open Project Settings > Environment Variables and add:
  • VAQUILL_API_KEY = vq_key_your_key_here
Redeploy if Vercel did not pick up the variable automatically.
You can also use the GitHub integration: push to a repo, import in the Vercel dashboard, set env vars, and every push redeploys.

Railway

Self-hosted

The build produces a standalone Next.js bundle (output: "standalone" in next.config.js). Any Node 18+ host works:

Troubleshooting

Always check the browser console and server logs first. The proxy surfaces the underlying Vaquill API error verbatim.
No response from chat
  • Verify VAQUILL_API_KEY is set in .env.local (or in your deployment platform).
  • Test the key directly: curl -H "Authorization: Bearer vq_key_..." https://api.vaquill.ai/api/v1/health.
  • Check that you have credits at app.vaquill.ai/billing.
Module not found errors after upgrading
iframe blocked by parent CSP The widget sends permissive CORS headers, but the embedding site’s Content-Security-Policy may block iframes. Add the widget origin to the parent’s frame-src directive. Streaming stops mid-response Some reverse proxies buffer SSE. If you deploy behind Nginx, disable buffering for the /api/chat/stream location:

Docker Widget

Self-host with Docker Compose and embed via script tag.

Widget Pro

Adds multi-thread sidebar, voice mode, and gamification.

Statutes Search API

The endpoint this widget proxies.

GitHub

Source code and issue tracker.