# Configuration

> Every option init() takes, with a full example and the plugins that are on by default.

`init` takes an optional config object with one key per plugin.

## Full example

This sets every plugin and every option. Each plugin’s page covers its options in detail.

*use-xerlock.ts*

```ts
import { open } from '@op-engineering/op-sqlite';
import AsyncStorage from '@react-native-async-storage/async-storage';
import { useNavigationContainerRef } from '@react-navigation/native';
import { QueryClient } from '@tanstack/query-core';
import {
  callableAction,
  dispatchable,
  expoSqliteAdapter,
  init,
  opSqliteAdapter,
} from '@xerlock/client';
import * as Notifications from 'expo-notifications';
import * as SecureStore from 'expo-secure-store';
import * as SQLite from 'expo-sqlite';
import { useEffect } from 'react';
import { MMKV } from 'react-native-mmkv';

import { showNotification } from '../notifications/show-notification';
import { caseSlice, store, suspectsSlice } from '../redux/store';
import { useCaseStore, useSuspectStore } from '../zustand/stores';

const queryClient = new QueryClient();
const userPrefs = new MMKV({ id: 'user-prefs' });

export const useXerlock = () => {
  const navigationRef = useNavigationContainerRef();

  useEffect(() => {
    init({
      console: true,
      commands: true,
      network: {
        ignoreUrls: ['/health', /analytics/],
      },
      zustand: {
        stores: {
          case: useCaseStore,
          suspects: useSuspectStore,
        },
        historyLimit: 50,
        actions: [callableAction(useSuspectStore, 'addSuspect', ['Irene Adler'])],
      },
      redux: {
        store,
        actions: [
          caseSlice.actions,
          'app/reset',
          dispatchable(suspectsSlice.actions.added, { payload: 'Irene Adler' }),
        ],
      },
      storage: {
        asyncStorage: AsyncStorage,
        mmkv: { userPrefs },
        secureStore: SecureStore,
      },
      tanstackQuery: queryClient,
      database: {
        main: expoSqliteAdapter(SQLite.openDatabaseAsync('app.db')),
        cache: opSqliteAdapter(open({ name: 'cache.db' })),
      },
      navigation: { ref: navigationRef },
      notifications: {
        expoNotifications: Notifications,
        // Used instead of `expoNotifications` when both are set.
        onRemoteMessage: (message) => showNotification(message.notification),
      },
    });
  }, [navigationRef]);

  return navigationRef;
};
```

Show the full example

Caution

The `navigation` plugin needs the ref from `useNavigationContainerRef()`, so call `init` from a `useEffect` in the component that renders your navigation container, and pass the ref to that container too.

## Plugins

| Plugin                                       | Accepts                                    | On by default |
| -------------------------------------------- | ------------------------------------------ | ------------- |
| [`console`](/docs/sdk/console/)              | `boolean`                                  | Yes           |
| [`commands`](/docs/sdk/commands/)            | `boolean`                                  | Yes           |
| [`network`](/docs/sdk/network/)              | `boolean \| NetworkPluginConfig`           | Yes           |
| [`tanstackQuery`](/docs/sdk/tanstack-query/) | `false \| QueryClientLike`                 | No            |
| [`zustand`](/docs/sdk/zustand/)              | `false \| ZustandPluginConfig`             | No            |
| [`redux`](/docs/sdk/redux/)                  | `false \| ReduxPluginConfig`               | No            |
| [`storage`](/docs/sdk/storage/)              | `false \| StoragePluginConfig`             | No            |
| [`database`](/docs/sdk/database/)            | `false \| Record<string, DatabaseAdapter>` | No            |
| [`navigation`](/docs/sdk/navigation/)        | `false \| NavigationPluginConfig`          | No            |
| [`notifications`](/docs/sdk/notifications/)  | `false \| NotificationsPluginConfig`       | No            |

## Calling init again

Calling `init` again replaces the whole config. The connection to the desktop app is reused, so it’s safe to call from a `useEffect` that re-runs.

## Types

The config types exported from `@xerlock/client`:

* `XerlockConfig`
* `NetworkPluginConfig`
* `ZustandPluginConfig`
* `ReduxPluginConfig`
* `StoragePluginConfig`
* `NavigationPluginConfig`
* `NotificationsPluginConfig`
* `PluginOption`
* `PluginId`

Tip

In production builds `init` does nothing, so the config can stay in place.
