|
1 | 1 | # [Porto](https://porto.sh) x React Native |
2 | 2 |
|
3 | | -A Porto React Native template. |
4 | | - |
5 | | -## Quick Start |
6 | | - |
7 | | -### Prerequisites |
8 | | - |
9 | | -- [Node.js](https://nodejs.org) (LTS)<sup>1</sup> |
10 | | -- [Yarn Classic](https://classic.yarnpkg.com) (v1.22+)<sup>1</sup> |
11 | | -- [Expo](https://docs.expo.dev/get-started/installation) |
12 | | -- [EAS CLI](https://docs.expo.dev/build/introduction) |
13 | | -- iOS Requirements (skip if you're not building for iOS): |
14 | | - - Xcode 26.0<sup>2</sup> |
15 | | - - iOS Simulator 26.0<sup>2</sup> |
16 | | - - Ruby 3.4.6<sup>1</sup> |
17 | | - - Cocoapods 1.16.2<sup>1</sup> |
18 | | - - [fastlane](https://github.com/fastlane/fastlane): `brew install fastlane` |
19 | | -- Android Requirements (skip if you're not building for Android): |
20 | | - - Java 21.0.7<sup>3</sup> |
21 | | - - Gradle 9.0.0<sup>3</sup> |
22 | | - - Android Studio<sup>4</sup> |
23 | | -- Optional but highly recommended: |
24 | | - - [Expo Orbit](https://docs.expo.dev/build/orbit) |
25 | | - |
26 | | -<sup>1</sup> [mise](https://mise.jdx.dev) |
27 | | - |
28 | | -- Once you have `ruby` installed with `mise`, use it to install `cocoapods`. |
29 | | - |
30 | | -<sup>2</sup> [xcodes](https://github.com/XcodesOrg/xcodesApp) |
31 | | - |
32 | | -<sup>3</sup> [sdkman](https://sdkman.io): run `sdk env install` in repo root to auto install Java and Gradle |
33 | | - |
34 | | -<sup>4</sup> [JetBrains Toolbox](https://www.jetbrains.com/toolbox-app). |
35 | | -Once you have Android Studio installed: |
36 | | - |
37 | | -- install a newer SDK Platform Tools - I use 36.1 ([demo](https://share.cleanshot.com/KJ6rYZjw)) |
38 | | -- install a newer virtual device with Google Play Services enabled - I use Pixel 9 Pro Fold ([demo](https://share.cleanshot.com/LhdhbMlS)) |
39 | | - |
40 | | -____ |
41 | | - |
42 | | -### Clone Repository & Install Dependencies |
43 | | - |
44 | | -```bash |
45 | | -gh repo clone ithacaxyz/porto-react-native |
46 | | -cd porto-react-native |
47 | | -yarn install |
48 | | -``` |
49 | | - |
50 | | -## Configuration |
51 | | - |
52 | | -When forking this project, update the following fields in `app.config.ts`: |
53 | | - |
54 | | -### Required Changes |
55 | | - |
56 | | -```typescript |
57 | | -export default (context: ConfigContext): ExpoConfig => ({ |
58 | | - // Update these fields: |
59 | | - slug: 'your-app-slug', // Line 8 |
60 | | - name: 'Your App Name', // Line 9 |
61 | | - scheme: 'your-app-scheme', // Line 10 |
62 | | - |
63 | | - ios: { |
64 | | - appleTeamId: 'YOUR_TEAM_ID', // Line 16 |
65 | | - bundleIdentifier: 'com.yourcompany.yourapp', // Line 17 |
66 | | - associatedDomains: ['webcredentials:your-domain.com'], // Line 18 |
67 | | - }, |
68 | | - android: { |
69 | | - package: 'com.yourcompany.yourapp', // Line 21 |
70 | | - }, |
71 | | - extra: { |
72 | | - eas: { |
73 | | - projectId: 'your-expo-project-id', // Line 32 |
74 | | - }, |
75 | | - }, |
76 | | -}) |
77 | | -``` |
78 | | - |
79 | | -### Getting Your Values |
80 | | - |
81 | | -1. **Apple Team ID**: Found in [Apple Developer Account](https://developer.apple.com/account) → Membership |
82 | | -2. **Bundle Identifier**: Use reverse domain notation (e.g., `com.yourcompany.yourapp`) |
83 | | -3. **EAS Project ID**: Create project at [expo.dev](https://expo.dev) and copy the project ID |
84 | | -4. **Associated Domain**: Your server domain where you'll host the app verification files |
85 | | - |
86 | | -## Server Directory (`./server`) |
87 | | - |
88 | | -The `./server` directory contains a [Bun](https://bun.sh) server that serves **App Verification Files** required for: |
89 | | - |
90 | | -### Purpose |
91 | | - |
92 | | -- **Passkey/WebAuthn**: Enables passkey authentication across web and mobile |
93 | | -- **Android App Links**: Verifies your app can handle Android deep links |
94 | | -- **iOS Universal Links**: Verifies your app can handle deep links from your domain |
95 | | - |
96 | | -### Files Served |
97 | | - |
98 | | -- `/.well-known/apple-app-site-association` - iOS app verification |
99 | | -- `/.well-known/assetlinks.json` - Android app verification |
100 | | - |
101 | | -### Deploying the Server |
102 | | - |
103 | | -I'm deploying to railway but you can deploy anywhere [./server/index.ts](../server/index.ts) can run. |
104 | | - |
105 | | -```bash |
106 | | -just deploy-server |
107 | | -``` |
108 | | - |
109 | | -## Apple Associated Domains Setup |
110 | | - |
111 | | -To enable Universal Links and passkey authentication: |
112 | | - |
113 | | -### 1. Update App Configuration |
114 | | - |
115 | | -In `app.config.ts`, set your domain: |
116 | | - |
117 | | -```typescript |
118 | | -ios: { |
119 | | - associatedDomains: ['webcredentials:yourdomain.com'], |
120 | | -} |
121 | | -``` |
122 | | - |
123 | | -### 2. Configure Apple App Site Association |
124 | | - |
125 | | -Update `server/apple-app-site-association`: |
126 | | - |
127 | | -```json |
128 | | -{ |
129 | | - "webcredentials": { |
130 | | - "apps": [ |
131 | | - "YOUR_TEAM_ID.your.bundle.identifier" |
132 | | - ] |
133 | | - } |
134 | | -} |
135 | | -``` |
136 | | - |
137 | | -### 3. Configure Android Asset Links |
138 | | - |
139 | | -Use `eas credentials` and follow [this guide](https://docs.expo.dev/linking/android-app-links/#create-assetlinksjson-file) and update `server/assetlinks.json`. |
140 | | - |
141 | | -### 5. Deploy and Verify |
142 | | - |
143 | | -1. Deploy your server with the updated files |
144 | | -2. Verify files are accessible: |
145 | | - - `https://yourdomain.com/.well-known/apple-app-site-association` |
146 | | - - `https://yourdomain.com/.well-known/assetlinks.json` |
147 | | -3. Test deep links and passkey functionality |
148 | | - |
149 | | -## Development |
150 | | - |
151 | | -### (0) - Clear Old Artifacts |
152 | | - |
153 | | -```sh |
154 | | -rm -fr '$TMPDIR/haste-map-*' |
155 | | -rm -fr '$TMPDIR/metro-cache' |
156 | | - |
157 | | -rm -rf ios |
158 | | -rm -rf android |
159 | | -``` |
160 | | - |
161 | | -### (1) - Prebuild |
162 | | - |
163 | | -Generate native `ios`/`android` directory, apply plugins and `build-properties` |
164 | | - |
165 | | -```bash |
166 | | -EXPO_NO_GIT_STATUS=1 yarn expo prebuild --platform='android' --clean |
167 | | -``` |
168 | | - |
169 | | -### (2) - Build with EAS CLI |
170 | | - |
171 | | -```bash |
172 | | -ANDROID_HOME="$HOME/Library/Android/sdk" EAS_BUILD_DISABLE_BUNDLE_JAVASCRIPT_STEP=1 eas build \ |
173 | | - --platform='android' \ |
174 | | - --non-interactive \ |
175 | | - --local |
176 | | -``` |
177 | | - |
178 | | -### (3) - Install App on Emulator/Simulator/Device |
179 | | - |
180 | | -- Android: |
181 | | - Your `.apk` file will have a dfferent number. Locate it in the repository root. |
182 | | - |
183 | | - ```sh |
184 | | - adb install -r build-1234567890.apk |
185 | | - ``` |
186 | | - |
187 | | -- iOS: |
188 | | - |
189 | | - ```sh |
190 | | - xcrun simctl install booted build-1234567890.ipa |
191 | | - ``` |
192 | | - |
193 | | -### (4) - Run Emulator/Android/iPhone |
194 | | - |
195 | | -```sh |
196 | | -yarn expo start --clear --tunnel --dev-client |
197 | | -``` |
198 | | - |
199 | | -### (5) - If using Android |
200 | | - |
201 | | -- Sign in to Google account on the emulator. |
202 | | - |
203 | | -### (6) - If using iOS |
204 | | - |
205 | | -- Make sure [Developer Mode](https://developer.apple.com/documentation/xcode/enabling-developer-mode-on-a-device) is enabled on the device. |
206 | | - |
207 | | -### (7) - Press: |
208 | | - |
209 | | -- `a` to run on Android. If your physical device is connected, it will automatically select it, |
210 | | -- `shift + a` to view Android options, |
211 | | -- `i` for iOS. Note that passkeys are not supported on iOS Simulator so you need to use an actual device, |
212 | | -- `w` for Web. |
213 | | -s. |
214 | | - |
215 | | -When you install / update dependencies, run the following to check dependencies are deduplicated: |
216 | | - |
217 | | -```bash |
218 | | -yarn expo install --fix && npx expo-doctor --verbose --yarn |
219 | | -``` |
220 | | - |
221 | | -If Expo doesn't resolve deduplication, run: `node_modules/.bin/bun scripts/dedupe.ts` |
222 | | - |
223 | | -### Available Commands (via [just](https://github.com/casey/just)) |
224 | | - |
225 | | -> [!IMPORTANT] |
226 | | -> |
227 | | -> You have to build at least once before you can run the app. |
228 | | -> You have to build any time you make changes to `app.config.ts` or to plugins or when you install new dependencies. |
229 | | -
|
230 | | -- `just build-ios` - Build iOS |
231 | | -- `just build-android` - Build Android |
232 | | - |
233 | | -- `just fmt` - Format code with Biome |
234 | | -- `just dev` - Run the app and launch web, android or ios |
235 | | -- `just doctor` - Fix dependencies and run expo doctor |
236 | | -- `just deploy-server` - Deploy server to Railway |
237 | | -- `just android-device` - Mirror Android device screen |
238 | | -- `just android-cert` - Generate Android debug certificate |
239 | | - |
240 | | -## Useful Links |
241 | | - |
242 | | -- [Expo Documentation](https://docs.expo.dev/) |
243 | | -- [Porto Documentation](https://porto.sh) |
244 | | -- [Apple Associated Domains](https://developer.apple.com/documentation/xcode/supporting-associated-domains) |
245 | | -- [Apple Universal Links](https://developer.apple.com/ios/universal-links/) |
246 | | -- [Android App Links](https://developer.android.com/training/app-links) |
247 | | -- [WebAuthn/Passkeys Guide](https://webauthn.guide/) |
| 3 | +See [Porto React Native docs](https://porto.sh/sdk/api/mode#modereactnative) for more information. |
0 commit comments