MMKV

active

by Tencent · since 2018 · also known as Tencent MMKV

Tencent's mmap-backed key-value store for mobile apps, built as a faster SharedPreferences/NSUserDefaults.

key-valueembedded libraryopen source (permissive)mature

Overview

MMKV is a small key-value storage framework from Tencent's WeChat team. It memory-maps a file, encodes values with protobuf and appends writes, so individual reads and writes take microseconds, and data survives crashes because the OS flushes mapped pages. It runs on Android, iOS, macOS, Windows, Linux, HarmonyOS and Flutter, supports multi-process access on Android, AES encryption and per-key expiry. It is the usual replacement for SharedPreferences, NSUserDefaults or AsyncStorage when those become a bottleneck. It is not a database for querying data: there are no indexes beyond the key.

Strengths & trade-offs

Strengths

  • +Microsecond reads and writes via mmap and append-only protobuf encoding
  • +Crash-safe without explicit sync calls
  • +Multi-process access on Android
  • +Runs on WeChat at very large install counts

Trade-offs

  • −Key-value only: no queries, indexes or transactions
  • −Files grow until compaction; large values waste memory
  • −Not a fit for structured or relational data

Great for

  • +Replacing SharedPreferences, NSUserDefaults or AsyncStorage
  • +Feature flags and user settings
  • +Small session and token caches on device

Think twice for

  • −Storing large or queryable datasets
  • −Server-side caching

Capabilities

Native or official first-party support · 3 of 25 tracked

✓TTL / expiry
✓Durable persistence
✓Encryption at rest
–Transactions
–Joins
–Secondary indexes
–Full-text search
–Vector search
–Geospatial
–JSON
–Change data capture
–Triggers
–Stored procedures
–Materialized views
–Pub/Sub
–Columnar storage
–In-memory
–Compression
–Role-based access
–Time travel
–Branching
–Online schema changes
–Streaming ingest
–Offline sync
–Runs in WebAssembly

Scale & consistency

Comfortable data size
Small · ≤ 100 GB
Horizontal scaling
None
Multi-region
No
Transactions
None
Consistency
Strong
Schema
Schemaless
Architecture
Embedded
Query languages
Key-value API

Designed for small values and app settings, not bulk data.

Deployment

Self-hosted Vendor-managed cloud Serverless Embedded Edge Kubernetes operator

Ecosystem

apis & protocolsNative SDKs
client languagesC++, Java, Kotlin, Objective-C, Swift, Dart, Python, Go
used byTencent (WeChat)

Alternatives to MMKV

Compare all→
Hive (Dart)Key-Value9.1

Lightweight pure-Dart key-value store for Flutter; development continues in the Hive CE fork.

mmkv vs hive-dart →
SQLiteRelational75.5

The in-process SQL engine that ships in every phone, browser and OS: one file, zero servers.

mmkv vs sqlite →
LMDBKey-Value39.7

Tiny memory-mapped B+tree with ACID transactions and lock-free readers; reached 1.0 in 2026.

mmkv vs lmdb →
ObjectBoxObject12.4

Fast on-device object database with built-in HNSW vector search and an optional commercial sync server.

mmkv vs objectbox →
Realm (Atlas Device SDK)Object25.2

Object-oriented mobile database whose MongoDB sync service is gone; the local engine survives as open source.

mmkv vs realm →
Cloudflare Workers KVKey-Value4.4

Globally cached, eventually consistent key-value store for read-heavy data at Cloudflare's edge.

mmkv vs cloudflare-workers-kv →

MMKV FAQ

What is MMKV?

MMKV is a key-value database by Tencent, first released in 2018. MMKV is a small key-value storage framework from Tencent's WeChat team. It memory-maps a file, encodes values with protobuf and appends writes, so individual reads and writes take microseconds, and data survives crashes because the OS flushes mapped pages. It runs on Android, iOS, macOS, Windows, Linux, HarmonyOS and Flutter, supports multi-process access on Android, AES encryption and per-key expiry. It is the usual replacement for SharedPreferences, NSUserDefaults or AsyncStorage when those become a bottleneck. It is not a database for querying data: there are no indexes beyond the key.

Is MMKV open source?

Yes. MMKV is open source. License: BSD 3-Clause License.

Does MMKV support ACID transactions?

No. MMKV does not provide ACID transactions; its consistency model is strong.

Does MMKV scale horizontally?

MMKV does not scale horizontally; it runs on a single node, so you scale it up rather than out. It is comfortable at small scale (≤ 100 GB).

How can I run MMKV?

You can self-host it and embed it in your application.

What is MMKV best for?

MMKV is a strong fit for replacing SharedPreferences, NSUserDefaults or AsyncStorage; feature flags and user settings; and small session and token caches on device. Think twice for storing large or queryable datasets.

What are the best alternatives to MMKV?

Common alternatives to MMKV include Hive (Dart), SQLite, LMDB, ObjectBox and Realm (Atlas Device SDK). The right choice depends on your workload, scale and hosting; WhichDB's smart match ranks them against your requirements.

How popular is MMKV?

MMKV ranks #364 of 844 databases on the WhichDB Score (6.3/100), and #51 among key-value databases. The score combines public adoption signals such as package downloads, GitHub activity, job posts and developer discussion.