惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

C
Check Point Blog
有赞技术团队
有赞技术团队
博客园 - 三生石上(FineUI控件)
博客园_首页
博客园 - 【当耐特】
WordPress大学
WordPress大学
月光博客
月光博客
博客园 - 叶小钗
S
SegmentFault 最新的问题
雷峰网
雷峰网
H
Help Net Security
宝玉的分享
宝玉的分享
A
About on SuperTechFans
IT之家
IT之家
J
Java Code Geeks
Hugging Face - Blog
Hugging Face - Blog
D
DataBreaches.Net
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 聂微东
T
The Blog of Author Tim Ferriss
B
Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Y
Y Combinator Blog

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
Client-Side Databases Are Underrated
Odejobi Abiola Samuel · 2026-06-21 · via DEV Community
Cover image for Client-Side Databases Are Underrated

Odejobi Abiola Samuel

For the last five years, I've worked on web apps that follow the same pattern: build a backend, set up Postgres, wire up REST endpoints, fetch data on the client, cache it in React state or Redux.

Somewhere along the way, I realized a lot of the data I was sending to the server never needed to go there.

Form drafts. UI preferences. Search indexes. Cached API responses. Offline queues. All of it lives on the client already — it just takes a detour through the network for no real reason.

The latency tax

A round-trip to the server costs 200-500ms on a fast connection. On mobile, it's worse. Multiply that by every interaction that needs data, and your app feels sluggish even when the UI is technically fast.

The typical fix is caching: store API responses in localStorage, serve stale data while re-fetching, invalidate caches manually. It works, but it's fighting the architecture. You're maintaining two copies of the same data — one in a cache, one in state — and hoping they stay in sync.

A client-side database flips the model: data lives where it's used. The server mediates shared state, auth, and writes that need coordination. Everything else stays in the browser.

What a client-side database gives you

The same primitives you'd expect from a server-side database, running in-process:

  • Schema validation at write time
  • Queries with filtering, sorting, and pagination
  • Indexes for fast lookups
  • Transactions for atomic multi-collection operations
  • Reactivity — subscribe to changes and re-render automatically

No network calls. No connection pooling. No serialization overhead.

A concrete example

I built ctrodb to explore this pattern. It's a client-side database that runs in the browser (IndexedDB) with zero dependencies:

import { Database } from "ctrodb"

const db = new Database({ name: "app" })
await db.connect()

const todos = db.collection("todos")
await todos.create({ title: "Try ctrodb", done: false })

const pending = await todos
  .query()
  .where("done", false)
  .sort({ createdAt: "desc" })
  .fetch()

Every record is a Model with typed field access. Update a record, and any React component using useQuery re-renders automatically.

When it makes sense

Client-side databases aren't for everything. But they shine for:

  • Offline-first apps — notes, tasks, journaling tools
  • Local-first architecture — data lives in the browser, sync with a server when needed
  • Search-heavy UIs — full-text search indexes can live on the client
  • Form-heavy apps — multi-step forms, draft-saving, autosave
  • Prototypes — skip the backend entirely during early development

The architecture shift

The mental model is subtle but powerful. Instead of "fetch from API → store in state → render", you think "query local database → render → sync to server".

Your UI becomes a view into a local database. No cache invalidation. No loading spinners for data that's already on disk. The database is the store.


If you're curious, ctrodb is open source. Check it out on npm at https://www.npmjs.com/package/ctrodb, try the playground at https://ctrodb.vercel.app/playground, or browse the docs at https://ctrodb.vercel.app/docs.