# Making a Bare Mobile Application This guide demonstrates how to build and run a mobile application using [Bare and Expo](https://github.com/holepunchto/bare-expo). We will be building an application that syncs data from the [Pearpass desktop application](https://github.com/holepunchto/pearpass-example/) using [autopass](https://github.com/holepunchto/autopass) and displaying a list of the passwords on mobile. ## Project Dependencies 1. Gradle version 8.10.2 2. Java 23 3. Android SDK (>= 28), NDK ## Project Setup We will use the `bare-expo` template to build our application. To get started, first clone it with git in a new directory: ```bash git clone https://github.com/holepunchto/bare-expo.git autopass-mobile-example ``` Change to the project directory: ```bash cd autopass-mobile-example ``` And install the dependencies we will need: ```bash npm i b4a bare-fs bare-rpc corestore autopass @react-native-clipboard/clipboard ``` ```bash npm i bare-pack --save-dev ``` ## Directory Structure `bare-expo` is a basic template for getting started with Bare applications on mobile. To build a "Pear-end", where the peer-to-peer (P2P) code of the application is run, we will change the directory structure a bit adding a dedicated directory for the Pear-end. Create a new directory called `backend`. This is where we will store our Pear-end code that will be run by Bare. ```bash mkdir backend ``` Create a new file `backend.mjs` in the `backend` directory, we will use this file as the entry point for anything P2P. All Bare code should be used here. ```bash touch backend/backend.mjs ``` Our React Native UI code will go in the existing `app/index.tsx` file. ## Building the Application ### Building the UI The `app/index.tsx` file that came with the `bare-expo` template serves as the entry point of the UI of the React Native app. Replace the contents of `app/index.tsx` with: ```typescript import React, { useState } from 'react' import { View, Text, TextInput, Button, FlatList, Platform, Alert, StyleSheet } from 'react-native' import Clipboard from '@react-native-clipboard/clipboard' import { Worklet } from 'react-native-bare-kit' import bundle from './app.bundle' import RPC from 'bare-rpc' import b4a from 'b4a' type PasswordEntry = { username: string password: string website: string } export default function App() { const [dataList, setDataList] = useState([]) const [pairingInvite, setPairingInvite] = useState('') // State for pairing invite const [isWorkletStarted, setIsWorkletStarted] = useState(false) // State to track worklet status const startWorklet = () => { const worklet = new Worklet() // Correctly passing the args to worklet.start worklet.start('/app.bundle', bundle, [Platform.OS, pairingInvite]) const { IPC } = worklet // Initialise RPC new RPC(IPC, (req) => { // Handle incoming RPC requests if (req.command === 'message') { const data = b4a.toString(req.data) const parsedData = JSON.parse(data) // Assuming data is a JSON string const entry: PasswordEntry = { username: parsedData[1], password: parsedData[2], website: parsedData[3] } // Update the dataList with the received entry setDataList((prevDataList) => [...prevDataList, entry]) } if (req.command === 'reset') { setDataList(() => []) } }) setIsWorkletStarted(true) // Mark worklet as started } const copyToClipboard = (item: PasswordEntry) => { Clipboard.setString(item.password) // Copy password to clipboard Alert.alert('Copied to Clipboard', item.password) } return ( Autopass-example 🍐 {!isWorkletStarted ? ( // Show input if worklet hasn't started <>