# Mobile SDK

The Self Mobile SDK Alpha provides React Native screen components and client infrastructure for integrating Self's identity verification flows into your mobile application.

## Installation

```bash
npm install @selfxyz/mobile-sdk-alpha
```

## Native Modules Setup

⚠️ **Important**: The Mobile SDK requires native module configuration for both Android and iOS platforms. Before using the SDK, you must complete the native setup:

* [**Native Modules Setup**](https://github.com/selfxyz/self-docs/blob/main/mobile-sdk/native-modules-setup.md) - Complete Android and iOS native configuration
* **Android**: MainActivity configuration, build.gradle setup, permissions

## Quick Start

The SDK requires two main integration points:

1. **SelfClientProvider** - Wraps your app with configured adapters and event listeners
2. **Screen Components** - Individual onboarding screens imported from specific paths

### Minimal Example

```tsx
import React from 'react';
import { View } from 'react-native';
import { 
  SelfClientProvider, 
  createListenersMap,
  type Adapters 
} from '@selfxyz/mobile-sdk-alpha';
import { DocumentCameraScreen } from '@selfxyz/mobile-sdk-alpha/onboarding/document-camera-screen';

// Configure adapters (see selfclient-provider.md for details)
const adapters: Adapters = {
  auth: {
    getPrivateKey: async () => "your-private-key"
  },
  scanner: yourNFCScannerAdapter,
  network: {
    http: { fetch },
    ws: { connect: (url) => new WebSocket(url) }
  },
  crypto: {
    hash: async (data) => /* hash implementation */,
    sign: async (data, keyRef) => /* signing implementation */
  },
  documents: yourDocumentStorageAdapter
};

// Configure event listeners for navigation
const listeners = createListenersMap();
const config = {};

function App() {
  return (
    <SelfClientProvider 
      config={config} 
      adapters={adapters} 
      listeners={listeners.map}
    >
      <View style={{ flex: 1 }}>
        <DocumentCameraScreen 
          onBack={() => console.log('Go back')}
          onSuccess={() => console.log('MRZ scan successful')}
        />
      </View>
    </SelfClientProvider>
  );
}
```

## Next Steps

* [**Native Modules Setup**](https://github.com/selfxyz/self-docs/blob/main/mobile-sdk/native-modules-setup.md) - Configure Android and iOS native modules
* [**SelfClient Provider Setup**](/self-pass/getting-started/selfclient-provider.md) - Configure adapters and event listeners
* [**Onboarding Screen Components**](/self-pass/getting-started/onboarding-screens.md) - Use the available screen components
* [**Implementation Examples**](/self-pass/getting-started/examples.md) - See complete integration patterns

## Important Notes

⚠️ **Alpha Status**: This SDK is in alpha. The interface may change as it matures. Many current configuration options may be removed or simplified in future versions.

✅ **Core Stability**: The two main integration patterns (SelfClientProvider + screen components) are expected to remain stable.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.self.xyz/self-pass/getting-started.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
