Skip to main content

Overview

The Mini App SDK enables communication between your web-based mini app and the Lemon Cash mobile application through React Native WebView technology. This communication bridge allows your mini app to request wallet authentication, deposit and withdrawal transactions, as well as smart contract interactions.

How it works

The communication flow follows a message-based architecture:
1

Mini app sends message

Your mini app sends a message to the native app using window.ReactNativeWebView.postMessage().
// Example: Sending authentication request
window.ReactNativeWebView.postMessage(JSON.stringify({
  action: 'AUTHENTICATE',
  nonce: 'l3m0nc45h'
}));
2

Lemon Cash processes the request

The Lemon Cash mobile app receives the message and processes the request. It will prompt the user to confirm the action before executing it.
3

Lemon Cash responds

The Lemon Cash mobile app sends a response back to your mini app using webViewRef.current.postMessage().
// Example: Authentication response
webViewRef.current.postMessage(JSON.stringify({
  action: 'AUTHENTICATE_RESPONSE',
  data: {
    wallet: '0x...',
    signature: '0x...',
    message: '...'
  }
}));
4

Mini app receives

Your mini app receives the response through event listeners and updates its state accordingly.

Environment Detection

The SDK provides a isWebView hook to detect if your app is running inside the Lemon Cash WebView:
import { isWebView } from '@lemonatio/mini-app-sdk';

function MyMiniApp() {  
  if (!isWebView()) {
    return <div>This app only works inside Lemon Cash</div>;
  }
  
  return <div>Welcome to your mini app!</div>;
}