Newsletter
Join the Community
Subscribe to our newsletter for the latest news and updates
Next.js template for building AI-powered, user-defined analytics UIs with MotherDuck embedded Dives.
MotherDuck Embedded Dives is a deployable Next.js boilerplate for building AI-powered, user-defined analytics apps that query MotherDuck — a serverless cloud data warehouse powered by DuckDB — through embedded, code-based Dives.
It is a starter template from MotherDuck that gives you a full Next.js application where visitors can browse starter Dives, open full-page previews, and use an AI chat interface to customize each Dive in place. The template takes MotherDuck credentials and an AI provider key as environment variables and outputs a live web app with a Dive gallery, preview routes, and a chat-based remix workflow. It runs on Vercel and can be deployed with a single click that provisions a MotherDuck integration, a Supabase Postgres integration for chat history, and runs database migrations from the migrations/ directory.
After you deploy with Vercel and add at least one AI key (ANTHROPIC_API_KEY, OPENAI_API_KEY, or AI_GATEWAY_API_KEY), visitors open the app, choose a Dive, and click Remix. In public demo mode, the first edit creates an anonymous MotherDuck service account and clones the starter Dives for that browser session, then the chat interface can modify the Dive's code and data queries. For local development, you run a Postgres container, set POSTGRES_URL, and run npm run dev.
A Dive is a code-based, fully customizable React component that queries MotherDuck, a serverless cloud data warehouse powered by DuckDB. Dives can be used to build interactive dashboards, presentations, or even data-driven games, and they fetch live data via SQL at runtime.
You must set MOTHERDUCK_TOKEN and POSTGRES_URL, plus at least one AI provider key: ANTHROPIC_API_KEY, OPENAI_API_KEY, or AI_GATEWAY_API_KEY. Optional overrides like AI_MODEL_ANTHROPIC, AI_MODEL_OPENAI, and AI_MODEL_GATEWAY allow you to change model defaults.
Yes. Load or attach your data in MotherDuck, then update the SQL in the starter Dive files. The project uses MotherDuck sample_data by default; for production, the page recommends modeling access with MotherDuck shares, per-user databases, or row-level filters.
No. The template's auth modes are for demo purposes. The README instructs you to connect your own identity provider, add authorization around users/workspaces/Dives/chat history/data access, add rate limits, and add monitoring before launching publicly.
Set the corresponding API key in Vercel project settings and optionally override the model with AI_MODEL_ANTHROPIC, AI_MODEL_OPENAI, or AI_MODEL_GATEWAY. The default models are claude-sonnet-4-6, gpt-5.4, and anthropic/claude-sonnet-4.6 respectively.
