Set up and configure Wavelet projects. Use when the user wants to add events, queries, or subscriptions to a wavelet.config.ts, integrate the Wavelet SDK or React hooks, or set up MCP for agent integration.
Set up and configure Wavelet projects. Use when the user wants to add events, queries, or subscriptions to a wavelet.config.ts, integrate the Wavelet SDK or React hooks, or set up MCP for agent integration.
Wavelet
Wavelet is a reactive backend that pushes pre-computed SQL query results to apps and AI agents over WebSocket.
Core Concepts
Events -- event ingestion tables. Defined with typed columns.
Queries -- SQL materialized views that incrementally recompute when source data changes.
Subscriptions -- WebSocket connections that receive diffs when a query changes.
npx wavelet init # Create wavelet.config.ts template
npx wavelet dev # Sync config to RisingWave + start server (auto-starts RisingWave)
npx wavelet push # Sync config to RisingWave without starting server
npx wavelet generate # Generate typed client at .wavelet/client.ts
npx wavelet status # Show config summary
All commands are idempotent.
SDK Usage
After running npx wavelet generate, a typed client is available at .wavelet/client.ts.
React
import { useWavelet } from'./.wavelet/client'functionComponent() {
const { data, isLoading, error } = useWavelet('query_name')
// data is fully typed based on the query's columns
}
Available tools: list_queries, query, list_events, emit_event, emit_batch, run_sql.
SQL Patterns for Queries
Queries are standard SQL running on RisingWave. Key patterns:
-- AggregationSELECT user_id, SUM(amount) AS total FROM orders GROUPBY user_id
-- Windowed aggregationSELECT user_id, COUNT(*) AS recent_orders
FROM orders WHERE created_at > NOW() -INTERVAL'1 hour'GROUPBY user_id
-- Threshold / alert (rows appear/disappear as condition changes)SELECT user_id, COUNT(*) AS tx_count
FROM transactions GROUPBY user_id HAVINGCOUNT(*) >100-- Join events with reference tablesSELECT o.*, u.name, p.category
FROM orders o JOIN users u ON o.user_id = u.id JOIN products p ON o.product_id = p.id
-- Window functionsSELECT symbol, price,
AVG(price) OVER (PARTITIONBY symbol ORDERBY ts ROWS50 PRECEDING) AS ma50
FROM trades
Common Tasks
Add a new event + query
Add event columns to wavelet.config.ts under events
Add a SQL query under queries that references the event table
Run npx wavelet dev (or npx wavelet push if server is already running)
Run npx wavelet generate to update the typed client
Add per-tenant filtering
Use the object form for the query with filterBy:
queries: {
my_query: {
query: sql`SELECT tenant_id, ... FROM ... GROUP BY tenant_id`,
filterBy: 'tenant_id',
}
}
The filterBy column must appear in the SELECT. Clients with a JWT containing { tenant_id: "t1" } only receive rows where tenant_id = 't1'.