Frontend Components
Skill: databricks-app-appkit
What You Can Build
Section titled “What You Can Build”You can build interactive dashboards using AppKit’s pre-built chart and table components that connect directly to SQL warehouse queries or accept static data. Pass a queryKey and the component handles fetching, loading states, and rendering — no manual data fetching or state management required.
In Action
Section titled “In Action”“Using TypeScript and React, build a dashboard page with a bar chart driven by a SQL query and a data table below it.”
import { BarChart, DataTable, Card, CardHeader, CardTitle, CardContent } from "@databricks/appkit-ui";
export function RevenueDashboard() { return ( <div className="grid gap-4"> <Card> <CardHeader> <CardTitle>Revenue by Region</CardTitle> </CardHeader> <CardContent> <BarChart queryKey="revenue_by_region" parameters={{}} xKey="region" yKey="revenue" /> </CardContent> </Card> <Card> <CardHeader> <CardTitle>Order Details</CardTitle> </CardHeader> <CardContent> <DataTable queryKey="recent_orders" parameters={{}} /> </CardContent> </Card> </div> );}Key decisions:
queryKeyreferences a SQL file inconfig/queries/(without the.sqlextension) — the component fetches data automaticallyparametersis required even when empty (parameters={{}}) — omitting it causes a runtime errorDataTableauto-generates columns from the query result — do not pass acolumnsprop- Use
xKeyandyKey(notxAxisKeyordataKey) — AppKit uses ECharts, not Recharts
More Patterns
Section titled “More Patterns”Static data mode for pre-fetched results
Section titled “Static data mode for pre-fetched results”“Using TypeScript and React, render a chart with data you already have in state.”
<BarChart data={salesData} xKey="category" yKey="count" orientation="horizontal" stacked={false}/>Data mode accepts an array of objects directly. Use it when your data comes from a tRPC endpoint, a computed transformation, or any source outside config/queries/. Do not pass queryKey and data on the same component.
Custom KPI cards with useAnalyticsQuery
Section titled “Custom KPI cards with useAnalyticsQuery”“Using TypeScript and React, fetch query results for a custom KPI layout.”
import { useMemo } from "react";import { useAnalyticsQuery } from "@databricks/appkit-ui";import { sql } from "@databricks/appkit-ui/js";
function KPICards({ selectedRegion }: { selectedRegion: string }) { const params = useMemo( () => ({ region: sql.string(selectedRegion) }), [selectedRegion] ); const { data, loading, error } = useAnalyticsQuery("kpi_metrics", params);
if (loading) return <Skeleton className="h-24" />; if (!data?.length) return null;
return ( <div className="grid grid-cols-3 gap-4"> <Card> <CardContent> <p className="text-2xl font-bold">{Number(data[0].total_revenue).toFixed(0)}</p> <p className="text-sm text-muted-foreground">Total Revenue</p> </CardContent> </Card> </div> );}useAnalyticsQuery is for custom layouts where pre-built components do not fit. Memoize the params object — without useMemo, React creates a new object on every render, triggering an infinite fetch loop. Use autoStart: false for conditional queries.
Available chart types
Section titled “Available chart types”“Using TypeScript and React, show different chart types for different data patterns.”
{/* Time series trends */}<LineChart queryKey="daily_revenue" parameters={{}} xKey="date" yKey="revenue" smooth />
{/* Cumulative totals */}<AreaChart queryKey="cumulative_users" parameters={{}} xKey="month" yKey="users" stacked />
{/* Part-of-whole breakdown */}<PieChart queryKey="category_share" parameters={{}} xKey="category" yKey="percentage" showLabels />
{/* Correlation analysis */}<ScatterChart queryKey="price_vs_rating" parameters={{}} xKey="price" yKey="rating" />
{/* Matrix visualization */}<HeatmapChart queryKey="hourly_traffic" parameters={{}} xKey="hour" yKey="day" />Each chart type supports the same queryKey/parameters pattern plus type-specific props like smooth, stacked, showLabels, innerRadius, and symbolSize.
Watch Out For
Section titled “Watch Out For”- Using Recharts prop names — AppKit wraps ECharts, not Recharts. Props like
xAxisKey,dataKey,<XAxis>, and<YAxis>do not exist. UsexKeyandyKeyand configure everything through props, not JSX children. - Omitting
parameterson query-driven components — even if your query has no parameters, you must passparameters={{}}. The component throws at runtime without it. - Double-fetching by combining
useAnalyticsQuerywith query components —BarChart,LineChart, and friends handle their own data fetching when given aqueryKey. Do not fetch the same data withuseAnalyticsQueryand pass it asdata— you will execute the query twice. - Creating params objects inline without
useMemo—useAnalyticsQuery("query", { id: sql.string(val) })creates a new object reference every render, causing infinite refetching. Always memoize.