Dives Functions
SQL table functions for managing Dives, the interactive React data apps that query live MotherDuck data. These functions let you create, read, update, and delete Dives directly from SQL. Dives use the useSQLQuery hook to query data from within their React components and the useDiveState hook to sync shareable UI state to the URL.
These functions are executed server-side on MotherDuck. They are not available on local-only DuckDB connections.
Create your first Dive assisted by your AI-tool of choice using our MCP server. Or try out a minimal working example using only SQL.
SELECT * FROM MD_CREATE_DIVE(
title = 'PokeDuck',
content = '
import { useSQLQuery } from "@motherduck/react-sql-query";
export default function Dive() {
const { data } = useSQLQuery(
`SELECT PROMPT(''Suggest a duck type or pokemon and tell a fun fact about them'')`,
{ select: (rows) => Object.values(rows[0])[0] }
);
return <div><p>FUN FACT:</p><p>{JSON.stringify(data)}</p></div>;
}'
);
Available functions
MD_LIST_DIVES
List all Dives in your MotherDuck account with pagination support.
useSQLQuery hook
React hook for querying MotherDuck data from within Dives.
useDiveState hook
React hook for storing shareable UI state in MotherDuck Dives.
MD_GET_DIVE
Retrieve a Dive by ID including its full React component content.
MD_CREATE_DIVE
Create a new Dive in your MotherDuck account.
MD_UPDATE_DIVE_METADATA
Update a Dive's title or description without creating a new version.
MD_UPDATE_DIVE_CONTENT
Update a Dive's React component code, creating a new version.
MD_DELETE_DIVE
Permanently delete a Dive by ID.
MD_LIST_DIVE_VERSIONS
List all versions of a specific Dive with pagination support.
MD_GET_DIVE_VERSION
Retrieve a specific historical version of a Dive including its content.