Basalt, queried from every Worker.
Bind Basalt to a Worker and query views from the edge. Requests route to the nearest of 38 regions, with typical reads under 20 ms.
Bind Basalt to a Worker and query views from the edge. Requests route to the nearest of 38 regions, with typical reads under 20 ms.
The Basalt binding gives your Worker a typed client that speaks HTTP/2 to the closest region. Connections are pooled across requests, and results can be cached in the Cache API for a TTL you set per view.
Create a read token and add the binding to wrangler.toml. The client is available on env.BASALT in every request.
# create a binding for the edge-api Worker basalt connect cloudflare --worker edge-api --role readonly
Write plain SQL over the source. Basalt keeps the view current with every record and tracks lineage back to the topic, partition and offset.
CREATE MATERIALIZED VIEW revenue_by_min AS SELECT date_trunc('minute', ts) AS minute, currency, sum(amount) AS revenue, count(*) AS payments FROM payments WHERE status = 'captured' GROUP BY 1, 2;
Every view is an endpoint the moment it exists. Call it over REST, connect with any Postgres client, or use the SDK from your app.
curl https://api.basalt.dev/v1/views/revenue_by_min?limit=5 \ -H "Authorization: Bearer $BASALT_TOKEN"
Queries route to the closest of 38 regions based on the Worker's colo.
The binding exposes your views as typed methods, generated from their schema.
Cache results in the Cache API with a per-view TTL and purge on update.
Scoped tokens can read named views only and are stored as Worker secrets.