Skip to main content

React Native

This backend uses react-native-sqlite-storage.

Installation

Install Kikko packages and react-native-sqlite-storage:

yarn add @kikko-land/react @kikko-land/react-native-backend react-native-sqlite-storage

Then configure Kikko:

import {
DbProvider,
EnsureDbLoaded,
IInitDbClientConfig,
migrationsPlugin,
reactiveQueriesPlugin,
} from "@kikko-land/react";
import { reactNativeBackend } from "@kikko-land/react-native-backend";

const config: IInitDbClientConfig = {
dbName: "kikko-db",
dbBackend: reactNativeBackend({ name: (dbName) => `${dbName}.db` }),
plugins: [
migrationsPlugin({ migrations: [createNotesTable] }),
reactiveQueriesPlugin({ webMultiTabSupport: false }),
],
};

And then wrap your with DbProvider and EnsureDbLoaded(optional):

import { DbProvider, EnsureDbLoaded } from "@kikko-land/react";

<DbProvider config={config}>
<EnsureDbLoaded fallback={<Text>Loading db...</Text>}>
<App />
</EnsureDbLoaded>
</DbProvider>;

Code example: https://github.com/kikko-land/kikko-react-native-example