Storage adapters
The four factories that tell the Storage tab which stores exist, and what they may do to them.
Four factories, all built on the last one. Each returns a StorageAdapterDefinition for
storage.adapters; ids are assigned from the names as the provider starts, suffixed on collision.
import AsyncStorage from '@react-native-async-storage/async-storage';
import * as SecureStore from 'expo-secure-store';
import { createMMKV } from 'react-native-mmkv';
const mmkv = createMMKV();
const devtoolsConfig = {
storage: {
adapters: [
asyncStorageAdapter({ driver: AsyncStorage }),
mmkvAdapter({ driver: mmkv }),
secureStoreAdapter({ driver: SecureStore, keys: ['session', 'pin'] }),
defineStorageAdapter({
name: 'In-memory',
kind: 'sync',
getAllKeys: () => [...map.keys()],
getItem: (key) => map.get(key) ?? null,
setItem: (key, text) => {
map.set(key, text);
},
removeItem: (key) => {
map.delete(key);
},
}),
],
},
} satisfies DevtoolsConfig;| Factory | For |
|---|---|
asyncStorageAdapter({ driver }) | @react-native-async-storage/async-storage and anything copying its API. Uses getMany (v3) or multiGet (v1/v2) for batch reads when present. |
mmkvAdapter({ driver }) | react-native-mmkv, both majors. v4's remove and v3's delete are both accepted. Changes show live through addOnValueChangedListener. |
secureStoreAdapter({ driver, keys }) | expo-secure-store. Takes keys because the keychain cannot be listed, and an optional options passed through to every call. |
defineStorageAdapter({ ... }) | Anything else. Duck-types nothing; takes exactly what you hand it. |
Shared fields
All four accept these:
| Field | Type | What it does |
|---|---|---|
name | string | Shown in the store dropdown. The three library factories default it; defineStorageAdapter requires it. |
readOnly | boolean | Makes this store read-only, whatever storage.readOnly says. |
blacklist | RegExp | ((key: string) => boolean) | A key it matches is never listed, never read and never written. |
defineStorageAdapter also takes these two. The library factories set them for you:
| Field | Type | What it does |
|---|---|---|
supportedTypes | StorageValueType[] | What the store can actually hold: 'string', 'number', 'boolean', 'buffer'. Defaults to all four. |
kind | 'sync' | 'async' | The badge the tab shows. Defaults to 'async'. Never a branch: every read is awaited either way. |
defineStorageAdapter
Needs either getAllKeys or a fixed keys list. Passing keys is what turns enumeration off, and it
may be a function, resolved on every read, for an app that keeps its own list of what it stored. Then
any of getItem (required), getMany, setItem and removeItem.
Whether the tab can edit or delete is derived from which of those you provided, so a store you registered read-only in effect is read-only in the UI without a flag. Sync functions are fine everywhere: they are awaited, not branched on.
getItem may return a bare string | null, or a { text, valueType } when the type matters. That
second form is how mmkvAdapter keeps a stored 1 from rendering as "1", and what an edit is written
back through.
subscribe
Optional, on defineStorageAdapter. Give it a function that calls the listener with a key whenever your
store changes that key, and returns a function that stops listening. The tab listens only while it is
open, and re-reads just the key it was told about, and only if that value was already read or its row
is on screen. A key it hasn't read just joins the list, unread. mmkvAdapter wires this up from MMKV's
addOnValueChangedListener for you. AsyncStorage and SecureStore have no listener, so their changes
show when you press Refresh.
defineStorageAdapter({
name: 'Memory',
getAllKeys: () => [...cache.keys()],
getItem: (key) => cache.get(key) ?? null,
subscribe: (listener) => cache.onChange(listener),
});blacklist
A RegExp or a (key: string) => boolean. A key it matches is never listed, never read, and never
written. The filtering happens in the adapter, before the read, not in the view, so the value never
reaches memory at all. A /g regex is safe: lastIndex is reset before every test.
The summary says a blacklist is set, but never how many keys it matched. That is a count this tab deliberately never learns.
supportedTypes
The list of types the store can really hold, out of 'string', 'number', 'boolean' and
'buffer'; it defaults to all four. asyncStorageAdapter and
secureStoreAdapter declare ['string'] for you, since both hand back a string whatever went in; MMKV
takes all four.
The Add-key sheet offers only these types, so a write the store would have flattened is never offered in the first place. Binary is never offered for either creating or editing, since there is no text form of the bytes to round-trip.