---
title: "Instrumenting your NextJS application with OpenTelemetry and ClickStack"
description: "ClickPy, a Next.js app over ClickHouse serving 1.8 trillion rows of PyPI download data, is instrumented with OpenTelemetry via ClickStack (ClickHouse, HyperDX and an OTel collector) to capture browser sessions and distributed traces."
url: "https://swe.quest/articles/instrumenting-your-nextjs-application-with-opentelemetry-and-clickstack-d85c0f4f10071552"
canonical: "https://clickhouse.com/blog/instrumenting-your-app-with-otel-clickstack"
source: "ClickHouse"
published: "2025-09-04"
difficulty: "medium"
kind: "How-to"
reading_minutes: 17
tags: ["observability","javascript","react","analytics"]
---

# Instrumenting your NextJS application with OpenTelemetry and ClickStack

A post on [ClickHouse](https://swe.quest/sources/clickhouse.md), published 2025-09-04, 17 min read, How-to. Original: [https://clickhouse.com/blog/instrumenting-your-app-with-otel-clickstack](https://clickhouse.com/blog/instrumenting-your-app-with-otel-clickstack)

## Summary

ClickPy, a Next.js app over ClickHouse serving 1.8 trillion rows of PyPI download data, is instrumented with OpenTelemetry via ClickStack (ClickHouse, HyperDX and an OTel collector) to capture browser sessions and distributed traces. The HyperDX browser SDK adds session replay, console and network capture, and traceparent propagation that links frontend spans to server spans. The Node.js SDK is wired in through Next.js instrumentation.js with header-capture environment variables. Custom spans around a central query function record each ClickHouse query's timing, rows returned, settings and the dashboard component that issued it, so slow dashboard loads can be traced to specific queries and package properties.

Written by swe.quest, not by the author.

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

## Topics

- [Observability](https://swe.quest/tags/observability.md) (Reliability & operations)
- [JavaScript](https://swe.quest/tags/javascript.md) (Languages)
- [React](https://swe.quest/tags/react.md) (Web & mobile)
- [Analytics & OLAP](https://swe.quest/tags/analytics.md) (Data & databases)

## Prerequisites

- Next.js basics ([easy posts on React](https://swe.quest/tags/react.md?difficulty=easy))
- OpenTelemetry traces and spans ([easy posts on Observability](https://swe.quest/tags/observability.md?difficulty=easy))
- Node.js ([easy posts on JavaScript](https://swe.quest/tags/javascript.md?difficulty=easy))

## Keywords

ClickStack, OpenTelemetry, Next.js, HyperDX, ClickHouse, ClickPy, Vercel

## Related posts

- [Introducing ClickStack embedded in ClickHouse](https://swe.quest/articles/introducing-clickstack-embedded-in-clickhouse-5655542c4f7400aa.md): ClickHouse · 2026-03-05 · Medium · 8 min read · Observability, Build systems, C & C++, Analytics & OLAP
  Starting with ClickHouse 26.2, the ClickStack (HyperDX) observability UI ships inside the ClickHouse binary at /clickstack, adding about 4 MB, for local exploration of logs, traces, metrics and ClickHouse's own system tables.
- [Whats new in ClickStack - June + July](https://swe.quest/articles/whats-new-in-clickstack-june-july-1186a53145598aa7.md): ClickHouse · 2026-08-10 · Medium · 16 min read · Observability, Analytics & OLAP
  ClickStack's June–July update centers on traces: per-service colors in the waterfall, fixed-pixel minimum span widths, a minimap for navigating long traces, and display of OpenTelemetry span links.
- [ClickStack: A (half) year in review](https://swe.quest/articles/clickstack-a-half-year-in-review-cf0d67e92c68a1b1.md): ClickHouse · 2026-01-06 · Easy · 12 min read · Observability, Analytics & OLAP, Performance engineering
  ClickStack, the ClickHouse-based observability stack built on HyperDX and OpenTelemetry, shipped a run of features between its May launch and December.
- [Using Event Patterns in ClickStack to accelerate observability analysis](https://swe.quest/articles/using-event-patterns-in-clickstack-to-accelerate-observability-analysis-7a0fbc615de3ddd6.md): ClickHouse · 2025-11-26 · Medium · 9 min read · Observability, Analytics & OLAP, Algorithms
  ClickStack clusters logs and traces into event patterns at query time using the Drain3 template-mining algorithm, which runs in the browser via Pyodide (Python compiled to WebAssembly).
- [What's new in ClickStack. September '25.](https://swe.quest/articles/what-s-new-in-clickstack-september-25-cea5d142df9ea015.md): ClickHouse · 2025-09-30 · Medium · 7 min read · Observability, Analytics & OLAP, Open source
  ClickStack's September 2025 release adds JSON dashboard import/export in HyperDX, custom aggregations through any ClickHouse aggregate function (e.g. stddevPop), and user-supplied OTel Collector YAML.

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)
