DEV Community

Sandeep Kumar
Sandeep Kumar

Posted on

Say Goodbye to Google Analytics: Meet Glance, a Single-Binary, Svelte 5 + SQLite Self-Hosted Solution

We’ve all been there. You launch a new side project, a blog, or an indie SaaS. You want to see how many people are visiting, where they’re coming from, and which pages are popular.

Naturally, you think about adding Google Analytics. But then reality sets in:

  • You have to add an obnoxious, conversion-killing cookie consent banner to comply with GDPR/ePrivacy directives.
  • You have to navigate the monstrously complex Google Analytics 4 (GA4) dashboard, which feels like it requires a PhD in marketing to find basic pageview data.
  • You drag down your site's performance by loading heavy tracking scripts that adblockers are going to block anyway.

You could pay $9 to $19 a month for a privacy-focused SaaS alternative, but as a developer or system administrator, why pay a subscription fee when you can host it yourself?

Enter Glance—a privacy-first, self-hosted web analytics platform packaged into a single Go binary and SQLite database, complete with a stunning Svelte 5 dashboard. It gives you all the metrics you actually care about with zero maintenance overhead.


What is Glance?

Glance is a modern web analytics tool built for developers, homelab enthusiasts, and indie hackers. It is designed to solve a very specific problem: how to get clean, beautiful, real-time analytics without selling your users' data, bloating your site, or babysitting a complex database cluster.

Here is the one-liner hook: It’s a zero-maintenance, cookieless web analytics platform that runs entirely on your own infrastructure.

Key Technical Highlights:

  • Single Binary Deployment: Built with Go. No external runtimes, node modules, or interpreters required on your server.
  • SQLite Backend: No Postgres, ClickHouse, or Redis setup needed. Your entire analytics history lives in a single .db file.
  • Cookieless & Privacy-First: No cookies are set, which means no cookie banners are required under GDPR, CCPA, or PECR.
  • Svelte 5 Dashboard: A gorgeous, reactive, lightning-fast UI utilizing Svelte 5's cutting-edge Runes engine, MapLibre for visual geo-tracking, and LayerChart for smooth, interactive data visualizations.

Under the Hood: Solving the SQLite Write Bottleneck

If you’ve built or hosted analytics before, your spider-sense might be tingling right now.

"SQLite for analytics? What happens when my site gets a spike in traffic? Won't concurrent database writes lock SQLite and crash the server?"

This is a classic critique of SQLite in write-heavy environments. Glance solves this elegantly by avoiding direct, synchronous database writes on every pageview. Instead, it utilizes a highly efficient in-memory queue buffer and pre-aggregated rollups.

How the In-Memory Queue Works

When a user visits your site, the lightweight tracking script (glance.js) fires a quick POST request to the Go backend.

Instead of writing this event directly to disk, the Go server pushes the event into a fast, thread-safe in-memory queue. The HTTP request immediately returns a 202 Accepted status, freeing up the network connection in milliseconds.

[User Browser] ---> (glance.js POST) ---> [Go Web Server]
                                                |
                                       (In-Memory Queue)
                                                |
                                    [Background Worker Thread]
                                                |
                                       (Batch Write / Rollup)
                                                |
                                                v
                                        [SQLite Database]
Enter fullscreen mode Exit fullscreen mode

A background worker thread continuously flushes these buffered events in batches, performing pre-aggregated rollups. Hourly and daily stats are calculated in-memory and committed to SQLite in structured transactions. This minimizes disk I/O, prevents database locking, and allows Glance to comfortably handle thousands of concurrent visits on a cheap $4/month VPS.


The Frontend: Svelte 5, LayerChart, and MapLibre

A self-hosted tool shouldn't look like an unstyled bootstrap dashboard from 2012. Glance’s UI is built on the brand-new Svelte 5 framework, making the interface extraordinarily snappy and lightweight.

By leveraging Svelte 5's new reactivity system (Runes), the Glance dashboard updates in real-time as new hits stream in, without causing unnecessary DOM re-renders.

To give you premium-grade visual insights, Glance integrates:

  • LayerChart: A powerful visualization library built on top of Svelte and D3, providing smooth, responsive charts for pageviews, bounce rates, and session durations.
  • MapLibre: High-performance, vector-based geographical heatmaps that show you exactly where your traffic is originating globally—all processed locally on your hardware without leaking IP addresses to third-party mapping APIs.

Lightning Fast Tracking with glance.js

The client-side tracker, located in server/internal/api/glance.js, is designed to be as unobtrusive as possible.

  • Weight: Under 1KB gzipped.
  • Impact: Near-zero CPU footprint on the client side.
  • No Cookies: It uses a cryptographic hash of the IP address, User-Agent, and a daily rotating salt to generate a temporary session ID. This allows Glance to distinguish between unique visitors and returning pageviews over a 24-hour window without storing any PII (Personally Identifiable Information) or writing tracking cookies to the browser.

Getting Started: Deploy in 60 Seconds

Because Glance is packaged as a single Go binary, deployment is incredibly simple. If you are a fan of Docker, you can spin up an instance using this basic docker-compose.yml:

version: '3.8'

services:
  glance:
    image: ghcr.io/yourusername/glance:latest # Replace with actual image path
    container_name: glance-analytics
    ports:
      - "8081:8081"
    environment:
      - PORT=8081
      - APP_ENV=production
      - ADMIN_PASSWORD=your_secure_password_here
    volumes:
      - ./data:/app/data
    restart: unless-stopped
Enter fullscreen mode Exit fullscreen mode

Simply run:

docker compose up -d
Enter fullscreen mode Exit fullscreen mode

Once running, navigate to http://localhost:8081, set up your website profile, and copy-paste the generated script tag into your website's <head>:

<script defer src="https://your-analytics-domain.com/glance.js" data-site="your-site-id"></script>
Enter fullscreen mode Exit fullscreen mode

And that’s it! You are now gathering privacy-respecting, lightning-fast web analytics.


Why Indie Hackers & Devs are Switching

  1. GDPR Peace of Mind: Because Glance does not collect personal data or use tracking cookies, you don’t need a cookie consent banner. Your site instantly looks cleaner and more professional.
  2. Zero Maintenance: No database clusters to update. Backing up your entire analytics history is as simple as copying the glance.db SQLite file to an S3 bucket or your local machine.
  3. Infrastructure Consolidation: You don't need a separate server. Because Glance's footprint is so small (often idling at less than 20MB of RAM), you can run it on the same VPS as your main application without worrying about resource exhaustion.
  4. Data Ownership: Your data is yours. No third-party ad networks are scraping your users' behavior to build advertising profiles.

Wrap Up

Glance is a testament to how powerful the modern minimalist developer stack can be. By combining the speed of Go, the simplicity and reliability of SQLite, and the reactivity of Svelte 5, you get a production-ready software suite that stands toe-to-toe with proprietary SaaS platforms—all running on a single container.

Have you tried self-hosting your analytics? What are your thoughts on using SQLite for write-heavy tracking applications? Let’s chat in the comments below!

Top comments (1)

Collapse
 
raknaos profile image
Baptiste Le Bouquin

Queueing writes in memory and flushing pre-aggregated rollups is the right architecture for SQLite — WAL mode plus batched transactions goes much further than most people expect. The edge I'd pressure-test: what happens to the buffer when the process dies between the 202 and the flush? Pure in-memory means a crash silently drops that window of pageviews. For analytics that's often an acceptable trade, but it's worth a line in the docs — the first person who restarts the container mid-spike and watches totals dip will assume the tracker is broken. Exposing current queue depth on a health endpoint would make the flush lag observable too.

On the privacy claim: the daily-salted IP+UA hash is better than most implementations, but a hashed identifier derived from an IP can still be personal data under GDPR if re-identification is realistically possible — Recital 26's "means likely reasonably to be used" test. The 24-hour rotation helps a lot by capping the linkage window; whether that fully avoids the consent question is a legal judgment rather than a technical one. A doc line stating exactly what gets hashed and for how long would preempt the first question every EU-based user asks.

The sub-20MB footprint and single-file backup are the parts that sell me. Nice work.