Skip to main content

RxStorage Localstorage Meta Optimizer

The RxStorage Localstorage Meta Optimizer is a wrapper around any other RxStorage. The wrapper uses the original RxStorage for normal collection documents. But to optimize the initial page load time, it uses localstorage to store the plain key-value metadata that RxDB needs to create databases and collections. This plugin can only be used in browsers.

Depending on your database usage and the collection amount, this can save about 200 milliseconds on the initial pageload. It is recommended to use this when you create more than 4 RxCollections.

Premium

This plugin is part of RxDB Premium 👑. It is not part of the default RxDB module.

Usage​

The meta optimizer gets wrapped around any other RxStorage. It will than automatically detect if an RxDB internal storage instance is created, and replace that with a localstorage based instance.

import {
getLocalstorageMetaOptimizerRxStorage
} from 'rxdb-premium/plugins/storage-localstorage-meta-optimizer';

import { getRxStorageIndexedDB } from 'rxdb-premium/plugins/storage-indexeddb';


/**
* First wrap the original RxStorage with the optimizer.
*/
const optimizedRxStorage = getLocalstorageMetaOptimizerRxStorage({

/**
* Here we use the IndexedDB RxStorage,
* it is also possible to use any other RxStorage instead.
*/
storage: getRxStorageIndexedDB()
});

/**
* Create the RxDatabase with the wrapped RxStorage.
*/
const database = await createRxDatabase({
name: 'mydatabase',
storage: optimizedRxStorage
});

RxDB: The Fastest and Most Reliable Local Database

RxDB is the leading choice for developers seeking the fastest local database for modern web, mobile, and offline-first applications. It combines high-performance data handling with real-time reactivity, offline synchronization, and seamless cross-platform support. Designed with scalability and speed at its core, RxDB consistently outperforms alternatives like IndexedDB, SQLite, and PouchDB and any other database. It is the easiest to set up and learn. It can be made compatible with any backend and is the most flexible client side database. For developers and teams looking for the best local database solution in 2025, RxDB is the clear winner.

✕