---
title: "Building single page applications with ClickHouse"
description: "ClickHouse can serve as a direct browser-queried backend for single page applications, removing the API server layer for demos, prototypes and analytics UIs."
url: "https://swe.quest/articles/building-single-page-applications-with-clickhouse-59259114384b9655"
canonical: "https://clickhouse.com/blog/building-single-page-applications-with-clickhouse-and-http"
source: "ClickHouse"
published: "2024-10-10"
difficulty: "medium"
kind: "How-to"
reading_minutes: 20
tags: ["analytics","frontend","identity-auth","api-design","javascript"]
---

# Building single page applications with ClickHouse

A post on [ClickHouse](https://swe.quest/sources/clickhouse.md), published 2024-10-10, 20 min read, How-to. Original: [https://clickhouse.com/blog/building-single-page-applications-with-clickhouse-and-http](https://clickhouse.com/blog/building-single-page-applications-with-clickhouse-and-http)

## Summary

ClickHouse can serve as a direct browser-queried backend for single page applications, removing the API server layer for demos, prototypes and analytics UIs. Doing this safely depends on HTTPS-only access, CORS configuration, parameterized queries to prevent SQL injection, read-only users with role-based access control, query complexity limits and quotas to stop rogue clients from overwhelming the database. Practical guidance covers choosing JSON output formats (streamable EachRow variants for large results, Arrow for high-volume rendering), reading progress and summary headers, the \`wait\_end\_of\_query\` tradeoff, handling mid-stream errors returned with HTTP 200, and preferring the official @clickhouse/client-web library. ClickHouse Cloud Query Endpoints are suggested for teams wanting an API layer instead.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Analytics & OLAP](https://swe.quest/tags/analytics.md) (Data & databases)
- [Frontend](https://swe.quest/tags/frontend.md) (Web & mobile)
- [Identity & auth](https://swe.quest/tags/identity-auth.md) (Security)
- [API design](https://swe.quest/tags/api-design.md) (Backend & APIs)
- [JavaScript](https://swe.quest/tags/javascript.md) (Languages)

## Prerequisites

- SQL basics ([easy posts on SQL](https://swe.quest/tags/sql.md?difficulty=easy))
- JavaScript fetch API ([easy posts on JavaScript](https://swe.quest/tags/javascript.md?difficulty=easy))
- HTTP and CORS

## Keywords

ClickHouse, ClickHouse Cloud, Query Endpoints, @clickhouse/client-web, JSONEachRow, CORS, ClickPy

## Related posts

- [Announcing the new ClickHouse SQL Playground](https://swe.quest/articles/announcing-the-new-clickhouse-sql-playground-3d79733825c39f99.md): ClickHouse · 2024-10-31 · Medium · 7 min read · Analytics & OLAP, Frontend, API design
  sql.clickhouse.com is a new public SQL playground offering over 35 datasets (60 TB) and 220 example queries, with syntax highlighting, autocomplete, query parameters, basic charting via Apache ECharts and shareable links.
- [ClickHouse as a streaming HTTP API](https://swe.quest/articles/clickhouse-as-a-streaming-http-api-20b4965fc67cb6c7.md): ClickHouse · 2026-09-05 · Medium · 16 min read · Analytics & OLAP, API design, SQL
  ClickHouse 26.8 can serve a parameterized HTTP API directly, removing the thin API layer often placed in front of it.
- [ClickHouse Plugin for Grafana - 2.0 Release](https://swe.quest/articles/clickhouse-plugin-for-grafana-2-0-release-6cc77a953b0e269e.md): ClickHouse · 2022-09-02 · Medium · 9 min read · Analytics & OLAP, Observability, SQL
  Version 2.0 of the ClickHouse Grafana plugin drops its client-side SQL AST parser and implements ad-hoc filters with ClickHouse's new \`additional\_table\_filters\` setting (22.7+), so the server injects each filter into the correct clauses, including subqueries.
- [Adding Analytics to an Application in under 10 minutes with ClickHouse Cloud Query Endpoints](https://swe.quest/articles/adding-analytics-to-an-application-in-under-10-minutes-with-clickhouse-cloud-8026d8ff6e788ea8.md): ClickHouse · 2024-09-24 · Medium · 9 min read · Analytics & OLAP, API design, SQL, React
  ClickHouse Cloud's beta API endpoints turn a saved parameterized SQL query into a secure HTTP POST endpoint, moving SQL out of application code so queries can change without redeploying.
- [Adding Real Time Analytics to a Supabase Application With ClickHouse](https://swe.quest/articles/adding-real-time-analytics-to-a-supabase-application-with-clickhouse-e40be6671b77f55d.md): ClickHouse · 2023-05-15 · Medium · 16 min read · Analytics & OLAP, PostgreSQL, System design, Frontend
  HouseClick, a demo estate-agency app, keeps ~1000 current listings in Supabase Postgres and serves analytics over the ~30M-row UK house price dataset from ClickHouse Cloud.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
