Build Data Apps with the anfra JS SDK
A Data App is one HTML file in `apps/` that asks for metrics by name through the JS SDK, and `anfra serve` runs it.
A Data App is a single HTML file in your repo's apps/ folder. It draws with any HTML, CSS and charting library, and gets its data from the Anfra global, which the host provides before the page's first script runs. There is nothing to install or import.
const app = Anfra.createApp({ title: 'Sales' })
const status = app.createFilter('status', { dataset: 'ecommerce', field: 'orders.status' })
const byRegion = app.createQuery('byRegion', {
dataset: 'ecommerce',
aql: 'explore { dimensions { region: users.region } measures { revenue: sum(orders.amount) } }',
})
app.mapControl(status, byRegion, { field: 'orders.status' })
app.subscribe(() => render(byRegion.result))
await app.execute()Queries name datasets and metrics, never SQL. You declare filters, date drills and cross-filters between queries, and the server turns each into the query it runs.
anfra serve serves every app under /apps/: apps/revenue.html opens at http://127.0.0.1:7878/apps/revenue, and reloads as you or your agent edit it.