react-native-flipper-databases
Flipper Databases plugin for React Native


This React Native plugin allows browsing popular React Native databases using Flipper built-in Databases plugin.

Installation
yarn add -D react-native-flipper react-native-flipper-databases
Setup
iOS
No particular setup is required on iOS.
Android
Since Android already provide a built-in Databases plugin (see official docs here for more details) in order to avoid conflicts with react-native-flipper-databases
it must be disabled.
Edit ReactNativeFlipper.java
file under android/app/src/debug/java/<your-app-package>
like this
...
import com.facebook.flipper.plugins.crashreporter.CrashReporterPlugin;
import com.facebook.flipper.plugins.fresco.FrescoFlipperPlugin;
import com.facebook.flipper.plugins.inspector.DescriptorMapping;
import com.facebook.flipper.plugins.inspector.InspectorFlipperPlugin;
import com.facebook.flipper.plugins.network.FlipperOkhttpInterceptor;
import com.facebook.flipper.plugins.network.NetworkFlipperPlugin;
import com.facebook.flipper.plugins.react.ReactFlipperPlugin;
import com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPlugin;
...
public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) {
if (FlipperUtils.shouldEnableFlipper(context)) {
final FlipperClient client = AndroidFlipperClient.getInstance(context);
client.addPlugin(new InspectorFlipperPlugin(context, DescriptorMapping.withDefaults()));
client.addPlugin(new ReactFlipperPlugin());
client.addPlugin(new SharedPreferencesFlipperPlugin(context));
client.addPlugin(CrashReporterPlugin.getInstance());
...
See facebook/flipper#1628 for more details.
Expo
When sticking to a managed Expo project, it's impossible to make the necessary modifications to the ReactNativeFlipper.java
file.
@liamdawson wrote a basic plugin to automate those changes, which will ensure Expo prebuild and builds via EAS will disable the integrated Databases plugin on Android.
See @liamdawson/disable-react-native-flipper-databases-expo-plugin for more info.
Usage
Compatibility
Setup
Attach a WatermelonDB database:
if (__DEV__) {
const { connectDatabases, WatermelonDB } = require('react-native-flipper-databases');
connectDatabases([
new WatermelonDB(database),
]);
}
Setup
Attach an open Realm:
const realm = await Realm.open(config);
if (__DEV__) {
const { connectDatabases, RealmDB } = require('react-native-flipper-databases');
connectDatabases([
new RealmDB('Realm', realm),
]);
}
Setup
Attach an open PouchDB database:
const db = new PouchDB('db', {
adapter: 'react-native-sqlite',
});
if (__DEV__) {
const {
connectDatabases,
PouchDB: PouchDBDriver,
} = require('react-native-flipper-databases');
connectDatabases([
new PouchDBDriver([db]),
]);
}
Setup
Attach an open Vasern database:
export const VasernDB = new Vasern({
});
if (__DEV__) {
const {
connectDatabases,
VasernDB: VasernDBDriver,
} = require('react-native-flipper-databases');
connectDatabases([
new VasernDBDriver(VasernDB),
]);
}
Setup
Attach an open SQLite database (with Promise support enabled)
SQLite.enablePromise(true);
async function openDatabase() {
const db = await SQLite.openDatabase({ name: 'data.db' });
if (__DEV__) {
const { connectDatabases, SQLiteStorage } = require('react-native-flipper-databases');
connectDatabases([
new SQLiteStorage([
{
name: 'data.db',
database: db,
},
]),
]);
}
return db;
}
Setup
import { openDatabase } from 'react-native-quick-sqlite'
if (__DEV__) {
const {
connectDatabases,
QuickSQLiteStorage,
} = require('react-native-flipper-databases');
openDatabase(
{ name: 'data.db' },
(db) => {
connectDatabases([
new QuickSQLiteStorage([
{
name: 'data.db',
database: db,
},
]),
])
},
() => {},
)
}
Examples
To see how to implement this plugin and test how it works some examples are provided.
To run the examples:
git clone https://codeberg.org/panz3r/react-native-flipper-databases.git
yarn bootstrap
The plugin integrations are located inside the src/infrastructure/database
folder of each example app.
Contributing
See the contributing guide to learn how to contribute to the repository and the development workflow.
License
MIT
Made with :sparkles: & :heart: by Mattia Panzeri and contributors