@codyswann/lisa 2.111.0 → 2.112.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/plugins/lisa/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-expo/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-expo/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-expo/.mcp.json +3 -3
- package/plugins/lisa-expo/THIRD-PARTY-NOTICES.md +57 -0
- package/plugins/lisa-expo/skills/add-app-clip/SKILL.md +280 -0
- package/plugins/lisa-expo/skills/add-app-clip/agents/openai.yaml +4 -0
- package/plugins/lisa-expo/skills/add-app-clip/references/native-module.md +96 -0
- package/plugins/lisa-expo/skills/building-native-ui/SKILL.md +321 -0
- package/plugins/lisa-expo/skills/building-native-ui/agents/openai.yaml +4 -0
- package/plugins/lisa-expo/skills/building-native-ui/references/animations.md +220 -0
- package/plugins/lisa-expo/skills/building-native-ui/references/controls.md +272 -0
- package/plugins/lisa-expo/skills/building-native-ui/references/form-sheet.md +253 -0
- package/plugins/lisa-expo/skills/building-native-ui/references/gradients.md +106 -0
- package/plugins/lisa-expo/skills/building-native-ui/references/icons.md +213 -0
- package/plugins/lisa-expo/skills/building-native-ui/references/media.md +198 -0
- package/plugins/lisa-expo/skills/building-native-ui/references/route-structure.md +229 -0
- package/plugins/lisa-expo/skills/building-native-ui/references/search.md +248 -0
- package/plugins/lisa-expo/skills/building-native-ui/references/storage.md +121 -0
- package/plugins/lisa-expo/skills/building-native-ui/references/tabs.md +433 -0
- package/plugins/lisa-expo/skills/building-native-ui/references/toolbar-and-headers.md +284 -0
- package/plugins/lisa-expo/skills/building-native-ui/references/visual-effects.md +197 -0
- package/plugins/lisa-expo/skills/building-native-ui/references/webgpu-three.md +605 -0
- package/plugins/lisa-expo/skills/building-native-ui/references/zoom-transitions.md +158 -0
- package/plugins/lisa-expo/skills/eas-update-insights/SKILL.md +228 -0
- package/plugins/lisa-expo/skills/eas-update-insights/agents/openai.yaml +4 -0
- package/plugins/lisa-expo/skills/eas-update-insights/references/channel-insights-schema.md +47 -0
- package/plugins/lisa-expo/skills/eas-update-insights/references/update-insights-schema.md +69 -0
- package/plugins/lisa-expo/skills/expo-api-routes/SKILL.md +369 -0
- package/plugins/lisa-expo/skills/expo-api-routes/agents/openai.yaml +4 -0
- package/plugins/lisa-expo/skills/expo-brownfield/SKILL.md +54 -0
- package/plugins/lisa-expo/skills/expo-brownfield/agents/openai.yaml +4 -0
- package/plugins/lisa-expo/skills/expo-brownfield/references/brownfield-integrated.md +526 -0
- package/plugins/lisa-expo/skills/expo-brownfield/references/brownfield-isolated.md +402 -0
- package/plugins/lisa-expo/skills/expo-brownfield/references/comparison.md +63 -0
- package/plugins/lisa-expo/skills/expo-brownfield/references/troubleshooting.md +88 -0
- package/plugins/lisa-expo/skills/expo-cicd-workflows/SKILL.md +92 -0
- package/plugins/lisa-expo/skills/expo-cicd-workflows/agents/openai.yaml +4 -0
- package/plugins/lisa-expo/skills/expo-cicd-workflows/scripts/fetch.js +113 -0
- package/plugins/lisa-expo/skills/expo-cicd-workflows/scripts/package.json +11 -0
- package/plugins/lisa-expo/skills/expo-cicd-workflows/scripts/validate.js +85 -0
- package/plugins/lisa-expo/skills/expo-deployment/SKILL.md +190 -0
- package/plugins/lisa-expo/skills/expo-deployment/agents/openai.yaml +4 -0
- package/plugins/lisa-expo/skills/expo-deployment/references/app-store-metadata.md +479 -0
- package/plugins/lisa-expo/skills/expo-deployment/references/ios-app-store.md +355 -0
- package/plugins/lisa-expo/skills/expo-deployment/references/play-store.md +246 -0
- package/plugins/lisa-expo/skills/expo-deployment/references/testflight.md +58 -0
- package/plugins/lisa-expo/skills/expo-deployment/references/workflows.md +200 -0
- package/plugins/lisa-expo/skills/expo-dev-client/SKILL.md +164 -0
- package/plugins/lisa-expo/skills/expo-dev-client/agents/openai.yaml +4 -0
- package/plugins/lisa-expo/skills/expo-module/SKILL.md +141 -0
- package/plugins/lisa-expo/skills/expo-module/agents/openai.yaml +4 -0
- package/plugins/lisa-expo/skills/expo-module/references/config-plugin.md +90 -0
- package/plugins/lisa-expo/skills/expo-module/references/create-expo-module.md +206 -0
- package/plugins/lisa-expo/skills/expo-module/references/lifecycle.md +127 -0
- package/plugins/lisa-expo/skills/expo-module/references/module-config.md +48 -0
- package/plugins/lisa-expo/skills/expo-module/references/native-module.md +286 -0
- package/plugins/lisa-expo/skills/expo-module/references/native-view.md +171 -0
- package/plugins/lisa-expo/skills/expo-tailwind-setup/SKILL.md +480 -0
- package/plugins/lisa-expo/skills/expo-tailwind-setup/agents/openai.yaml +4 -0
- package/plugins/lisa-expo/skills/expo-ui-jetpack-compose/SKILL.md +40 -0
- package/plugins/lisa-expo/skills/expo-ui-jetpack-compose/agents/openai.yaml +4 -0
- package/plugins/lisa-expo/skills/expo-ui-swift-ui/SKILL.md +39 -0
- package/plugins/lisa-expo/skills/expo-ui-swift-ui/agents/openai.yaml +4 -0
- package/plugins/lisa-expo/skills/native-data-fetching/SKILL.md +507 -0
- package/plugins/lisa-expo/skills/native-data-fetching/agents/openai.yaml +4 -0
- package/plugins/lisa-expo/skills/native-data-fetching/references/expo-router-loaders.md +344 -0
- package/plugins/lisa-expo/skills/upgrading-expo/SKILL.md +134 -0
- package/plugins/lisa-expo/skills/upgrading-expo/agents/openai.yaml +4 -0
- package/plugins/lisa-expo/skills/upgrading-expo/references/expo-av-to-audio.md +132 -0
- package/plugins/lisa-expo/skills/upgrading-expo/references/expo-av-to-video.md +160 -0
- package/plugins/lisa-expo/skills/upgrading-expo/references/native-tabs.md +124 -0
- package/plugins/lisa-expo/skills/upgrading-expo/references/new-architecture.md +79 -0
- package/plugins/lisa-expo/skills/upgrading-expo/references/react-19.md +79 -0
- package/plugins/lisa-expo/skills/upgrading-expo/references/react-compiler.md +59 -0
- package/plugins/lisa-expo/skills/upgrading-expo/references/react-navigation-to-expo-router.md +61 -0
- package/plugins/lisa-expo/skills/use-dom/SKILL.md +417 -0
- package/plugins/lisa-expo/skills/use-dom/agents/openai.yaml +4 -0
- package/plugins/lisa-harper-fabric/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-openclaw/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-openclaw/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-rails/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-rails/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki/.codex-plugin/plugin.json +1 -1
- package/plugins/src/expo/.mcp.json +3 -3
- package/plugins/src/expo/THIRD-PARTY-NOTICES.md +57 -0
- package/plugins/src/expo/skills/add-app-clip/SKILL.md +280 -0
- package/plugins/src/expo/skills/add-app-clip/references/native-module.md +96 -0
- package/plugins/src/expo/skills/building-native-ui/SKILL.md +321 -0
- package/plugins/src/expo/skills/building-native-ui/references/animations.md +220 -0
- package/plugins/src/expo/skills/building-native-ui/references/controls.md +272 -0
- package/plugins/src/expo/skills/building-native-ui/references/form-sheet.md +253 -0
- package/plugins/src/expo/skills/building-native-ui/references/gradients.md +106 -0
- package/plugins/src/expo/skills/building-native-ui/references/icons.md +213 -0
- package/plugins/src/expo/skills/building-native-ui/references/media.md +198 -0
- package/plugins/src/expo/skills/building-native-ui/references/route-structure.md +229 -0
- package/plugins/src/expo/skills/building-native-ui/references/search.md +248 -0
- package/plugins/src/expo/skills/building-native-ui/references/storage.md +121 -0
- package/plugins/src/expo/skills/building-native-ui/references/tabs.md +433 -0
- package/plugins/src/expo/skills/building-native-ui/references/toolbar-and-headers.md +284 -0
- package/plugins/src/expo/skills/building-native-ui/references/visual-effects.md +197 -0
- package/plugins/src/expo/skills/building-native-ui/references/webgpu-three.md +605 -0
- package/plugins/src/expo/skills/building-native-ui/references/zoom-transitions.md +158 -0
- package/plugins/src/expo/skills/eas-update-insights/SKILL.md +228 -0
- package/plugins/src/expo/skills/eas-update-insights/references/channel-insights-schema.md +47 -0
- package/plugins/src/expo/skills/eas-update-insights/references/update-insights-schema.md +69 -0
- package/plugins/src/expo/skills/expo-api-routes/SKILL.md +369 -0
- package/plugins/src/expo/skills/expo-brownfield/SKILL.md +54 -0
- package/plugins/src/expo/skills/expo-brownfield/references/brownfield-integrated.md +526 -0
- package/plugins/src/expo/skills/expo-brownfield/references/brownfield-isolated.md +402 -0
- package/plugins/src/expo/skills/expo-brownfield/references/comparison.md +63 -0
- package/plugins/src/expo/skills/expo-brownfield/references/troubleshooting.md +88 -0
- package/plugins/src/expo/skills/expo-cicd-workflows/SKILL.md +92 -0
- package/plugins/src/expo/skills/expo-cicd-workflows/scripts/fetch.js +113 -0
- package/plugins/src/expo/skills/expo-cicd-workflows/scripts/package.json +11 -0
- package/plugins/src/expo/skills/expo-cicd-workflows/scripts/validate.js +85 -0
- package/plugins/src/expo/skills/expo-deployment/SKILL.md +190 -0
- package/plugins/src/expo/skills/expo-deployment/references/app-store-metadata.md +479 -0
- package/plugins/src/expo/skills/expo-deployment/references/ios-app-store.md +355 -0
- package/plugins/src/expo/skills/expo-deployment/references/play-store.md +246 -0
- package/plugins/src/expo/skills/expo-deployment/references/testflight.md +58 -0
- package/plugins/src/expo/skills/expo-deployment/references/workflows.md +200 -0
- package/plugins/src/expo/skills/expo-dev-client/SKILL.md +164 -0
- package/plugins/src/expo/skills/expo-module/SKILL.md +141 -0
- package/plugins/src/expo/skills/expo-module/references/config-plugin.md +90 -0
- package/plugins/src/expo/skills/expo-module/references/create-expo-module.md +206 -0
- package/plugins/src/expo/skills/expo-module/references/lifecycle.md +127 -0
- package/plugins/src/expo/skills/expo-module/references/module-config.md +48 -0
- package/plugins/src/expo/skills/expo-module/references/native-module.md +286 -0
- package/plugins/src/expo/skills/expo-module/references/native-view.md +171 -0
- package/plugins/src/expo/skills/expo-tailwind-setup/SKILL.md +480 -0
- package/plugins/src/expo/skills/expo-ui-jetpack-compose/SKILL.md +40 -0
- package/plugins/src/expo/skills/expo-ui-swift-ui/SKILL.md +39 -0
- package/plugins/src/expo/skills/native-data-fetching/SKILL.md +507 -0
- package/plugins/src/expo/skills/native-data-fetching/references/expo-router-loaders.md +344 -0
- package/plugins/src/expo/skills/upgrading-expo/SKILL.md +134 -0
- package/plugins/src/expo/skills/upgrading-expo/references/expo-av-to-audio.md +132 -0
- package/plugins/src/expo/skills/upgrading-expo/references/expo-av-to-video.md +160 -0
- package/plugins/src/expo/skills/upgrading-expo/references/native-tabs.md +124 -0
- package/plugins/src/expo/skills/upgrading-expo/references/new-architecture.md +79 -0
- package/plugins/src/expo/skills/upgrading-expo/references/react-19.md +79 -0
- package/plugins/src/expo/skills/upgrading-expo/references/react-compiler.md +59 -0
- package/plugins/src/expo/skills/upgrading-expo/references/react-navigation-to-expo-router.md +61 -0
- package/plugins/src/expo/skills/use-dom/SKILL.md +417 -0
- package/scripts/generate-codex-plugin-artifacts.mjs +7 -2
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: expo-api-routes
|
|
3
|
+
description: Guidelines for creating API routes in Expo Router with EAS Hosting
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
license: MIT
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## When to Use API Routes
|
|
9
|
+
|
|
10
|
+
Use API routes when you need:
|
|
11
|
+
|
|
12
|
+
- **Server-side secrets** — API keys, database credentials, or tokens that must never reach the client
|
|
13
|
+
- **Database operations** — Direct database queries that shouldn't be exposed
|
|
14
|
+
- **Third-party API proxies** — Hide API keys when calling external services (OpenAI, Stripe, etc.)
|
|
15
|
+
- **Server-side validation** — Validate data before database writes
|
|
16
|
+
- **Webhook endpoints** — Receive callbacks from services like Stripe or GitHub
|
|
17
|
+
- **Rate limiting** — Control access at the server level
|
|
18
|
+
- **Heavy computation** — Offload processing that would be slow on mobile
|
|
19
|
+
|
|
20
|
+
## When NOT to Use API Routes
|
|
21
|
+
|
|
22
|
+
Avoid API routes when:
|
|
23
|
+
|
|
24
|
+
- **Data is already public** — Use direct fetch to public APIs instead
|
|
25
|
+
- **No secrets required** — Static data or client-safe operations
|
|
26
|
+
- **Real-time updates needed** — Use WebSockets or services like Supabase Realtime
|
|
27
|
+
- **Simple CRUD** — Consider Firebase, Supabase, or Convex for managed backends
|
|
28
|
+
- **File uploads** — Use direct-to-storage uploads (S3 presigned URLs, Cloudflare R2)
|
|
29
|
+
- **Authentication only** — Use Clerk, Auth0, or Firebase Auth instead
|
|
30
|
+
|
|
31
|
+
## File Structure
|
|
32
|
+
|
|
33
|
+
API routes live in the `app` directory with `+api.ts` suffix:
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
app/
|
|
37
|
+
api/
|
|
38
|
+
hello+api.ts → GET /api/hello
|
|
39
|
+
users+api.ts → /api/users
|
|
40
|
+
users/[id]+api.ts → /api/users/:id
|
|
41
|
+
(tabs)/
|
|
42
|
+
index.tsx
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Basic API Route
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
// app/api/hello+api.ts
|
|
49
|
+
export function GET(request: Request) {
|
|
50
|
+
return Response.json({ message: "Hello from Expo!" });
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## HTTP Methods
|
|
55
|
+
|
|
56
|
+
Export named functions for each HTTP method:
|
|
57
|
+
|
|
58
|
+
```ts
|
|
59
|
+
// app/api/items+api.ts
|
|
60
|
+
export function GET(request: Request) {
|
|
61
|
+
return Response.json({ items: [] });
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export async function POST(request: Request) {
|
|
65
|
+
const body = await request.json();
|
|
66
|
+
return Response.json({ created: body }, { status: 201 });
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export async function PUT(request: Request) {
|
|
70
|
+
const body = await request.json();
|
|
71
|
+
return Response.json({ updated: body });
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export async function DELETE(request: Request) {
|
|
75
|
+
return new Response(null, { status: 204 });
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Dynamic Routes
|
|
80
|
+
|
|
81
|
+
```ts
|
|
82
|
+
// app/api/users/[id]+api.ts
|
|
83
|
+
export function GET(request: Request, { id }: { id: string }) {
|
|
84
|
+
return Response.json({ userId: id });
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Request Handling
|
|
89
|
+
|
|
90
|
+
### Query Parameters
|
|
91
|
+
|
|
92
|
+
```ts
|
|
93
|
+
export function GET(request: Request) {
|
|
94
|
+
const url = new URL(request.url);
|
|
95
|
+
const page = url.searchParams.get("page") ?? "1";
|
|
96
|
+
const limit = url.searchParams.get("limit") ?? "10";
|
|
97
|
+
|
|
98
|
+
return Response.json({ page, limit });
|
|
99
|
+
}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Headers
|
|
103
|
+
|
|
104
|
+
```ts
|
|
105
|
+
export function GET(request: Request) {
|
|
106
|
+
const auth = request.headers.get("Authorization");
|
|
107
|
+
|
|
108
|
+
if (!auth) {
|
|
109
|
+
return Response.json({ error: "Unauthorized" }, { status: 401 });
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return Response.json({ authenticated: true });
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### JSON Body
|
|
117
|
+
|
|
118
|
+
```ts
|
|
119
|
+
export async function POST(request: Request) {
|
|
120
|
+
const { email, password } = await request.json();
|
|
121
|
+
|
|
122
|
+
if (!email || !password) {
|
|
123
|
+
return Response.json({ error: "Missing fields" }, { status: 400 });
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return Response.json({ success: true });
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## Environment Variables
|
|
131
|
+
|
|
132
|
+
Use `process.env` for server-side secrets:
|
|
133
|
+
|
|
134
|
+
```ts
|
|
135
|
+
// app/api/ai+api.ts
|
|
136
|
+
export async function POST(request: Request) {
|
|
137
|
+
const { prompt } = await request.json();
|
|
138
|
+
|
|
139
|
+
const response = await fetch("https://api.openai.com/v1/chat/completions", {
|
|
140
|
+
method: "POST",
|
|
141
|
+
headers: {
|
|
142
|
+
"Content-Type": "application/json",
|
|
143
|
+
Authorization: `Bearer ${process.env.OPENAI_API_KEY}`,
|
|
144
|
+
},
|
|
145
|
+
body: JSON.stringify({
|
|
146
|
+
model: "gpt-4",
|
|
147
|
+
messages: [{ role: "user", content: prompt }],
|
|
148
|
+
}),
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
const data = await response.json();
|
|
152
|
+
return Response.json(data);
|
|
153
|
+
}
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
Set environment variables:
|
|
157
|
+
|
|
158
|
+
- **Local**: Create `.env` file (never commit)
|
|
159
|
+
- **EAS Hosting**: Use `eas env:create` or Expo dashboard
|
|
160
|
+
|
|
161
|
+
## CORS Headers
|
|
162
|
+
|
|
163
|
+
Add CORS for web clients:
|
|
164
|
+
|
|
165
|
+
```ts
|
|
166
|
+
const corsHeaders = {
|
|
167
|
+
"Access-Control-Allow-Origin": "*",
|
|
168
|
+
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, OPTIONS",
|
|
169
|
+
"Access-Control-Allow-Headers": "Content-Type, Authorization",
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
export function OPTIONS() {
|
|
173
|
+
return new Response(null, { headers: corsHeaders });
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
export function GET() {
|
|
177
|
+
return Response.json({ data: "value" }, { headers: corsHeaders });
|
|
178
|
+
}
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
## Error Handling
|
|
182
|
+
|
|
183
|
+
```ts
|
|
184
|
+
export async function POST(request: Request) {
|
|
185
|
+
try {
|
|
186
|
+
const body = await request.json();
|
|
187
|
+
// Process...
|
|
188
|
+
return Response.json({ success: true });
|
|
189
|
+
} catch (error) {
|
|
190
|
+
console.error("API error:", error);
|
|
191
|
+
return Response.json({ error: "Internal server error" }, { status: 500 });
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
## Testing Locally
|
|
197
|
+
|
|
198
|
+
Start the development server with API routes:
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
npx expo serve
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
This starts a local server at `http://localhost:8081` with full API route support.
|
|
205
|
+
|
|
206
|
+
Test with curl:
|
|
207
|
+
|
|
208
|
+
```bash
|
|
209
|
+
curl http://localhost:8081/api/hello
|
|
210
|
+
curl -X POST http://localhost:8081/api/users -H "Content-Type: application/json" -d '{"name":"Test"}'
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
## Deployment to EAS Hosting
|
|
214
|
+
|
|
215
|
+
### Prerequisites
|
|
216
|
+
|
|
217
|
+
```bash
|
|
218
|
+
npm install -g eas-cli
|
|
219
|
+
eas login
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
### Deploy
|
|
223
|
+
|
|
224
|
+
```bash
|
|
225
|
+
eas deploy
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
This builds and deploys your API routes to EAS Hosting (Cloudflare Workers).
|
|
229
|
+
|
|
230
|
+
### Environment Variables for Production
|
|
231
|
+
|
|
232
|
+
```bash
|
|
233
|
+
# Create a secret
|
|
234
|
+
eas env:create --name OPENAI_API_KEY --value sk-xxx --environment production
|
|
235
|
+
|
|
236
|
+
# Or use the Expo dashboard
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
### Custom Domain
|
|
240
|
+
|
|
241
|
+
Configure in `eas.json` or Expo dashboard.
|
|
242
|
+
|
|
243
|
+
## EAS Hosting Runtime (Cloudflare Workers)
|
|
244
|
+
|
|
245
|
+
API routes run on Cloudflare Workers. Key limitations:
|
|
246
|
+
|
|
247
|
+
### Missing/Limited APIs
|
|
248
|
+
|
|
249
|
+
- **No Node.js filesystem** — `fs` module unavailable
|
|
250
|
+
- **No native Node modules** — Use Web APIs or polyfills
|
|
251
|
+
- **Limited execution time** — 30 second timeout for CPU-intensive tasks
|
|
252
|
+
- **No persistent connections** — WebSockets require Durable Objects
|
|
253
|
+
- **fetch is available** — Use standard fetch for HTTP requests
|
|
254
|
+
|
|
255
|
+
### Use Web APIs Instead
|
|
256
|
+
|
|
257
|
+
```ts
|
|
258
|
+
// Use Web Crypto instead of Node crypto
|
|
259
|
+
const hash = await crypto.subtle.digest(
|
|
260
|
+
"SHA-256",
|
|
261
|
+
new TextEncoder().encode("data")
|
|
262
|
+
);
|
|
263
|
+
|
|
264
|
+
// Use fetch instead of node-fetch
|
|
265
|
+
const response = await fetch("https://api.example.com");
|
|
266
|
+
|
|
267
|
+
// Use Response/Request (already available)
|
|
268
|
+
return new Response(JSON.stringify(data), {
|
|
269
|
+
headers: { "Content-Type": "application/json" },
|
|
270
|
+
});
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
### Database Options
|
|
274
|
+
|
|
275
|
+
Since filesystem is unavailable, use cloud databases:
|
|
276
|
+
|
|
277
|
+
- **Cloudflare D1** — SQLite at the edge
|
|
278
|
+
- **Turso** — Distributed SQLite
|
|
279
|
+
- **PlanetScale** — Serverless MySQL
|
|
280
|
+
- **Supabase** — Postgres with REST API
|
|
281
|
+
- **Neon** — Serverless Postgres
|
|
282
|
+
|
|
283
|
+
Example with Turso:
|
|
284
|
+
|
|
285
|
+
```ts
|
|
286
|
+
// app/api/users+api.ts
|
|
287
|
+
import { createClient } from "@libsql/client/web";
|
|
288
|
+
|
|
289
|
+
const db = createClient({
|
|
290
|
+
url: process.env.TURSO_URL!,
|
|
291
|
+
authToken: process.env.TURSO_AUTH_TOKEN!,
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
export async function GET() {
|
|
295
|
+
const result = await db.execute("SELECT * FROM users");
|
|
296
|
+
return Response.json(result.rows);
|
|
297
|
+
}
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
## Calling API Routes from Client
|
|
301
|
+
|
|
302
|
+
```ts
|
|
303
|
+
// From React Native components
|
|
304
|
+
const API_BASE_URL = process.env.EXPO_PUBLIC_API_BASE_URL!;
|
|
305
|
+
const response = await fetch(`${API_BASE_URL}/api/hello`);
|
|
306
|
+
const data = await response.json();
|
|
307
|
+
|
|
308
|
+
// With body
|
|
309
|
+
const response = await fetch(`${API_BASE_URL}/api/users`, {
|
|
310
|
+
method: "POST",
|
|
311
|
+
headers: { "Content-Type": "application/json" },
|
|
312
|
+
body: JSON.stringify({ name: "John" }),
|
|
313
|
+
});
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
## Common Patterns
|
|
317
|
+
|
|
318
|
+
### Authentication Middleware
|
|
319
|
+
|
|
320
|
+
```ts
|
|
321
|
+
// utils/auth.ts
|
|
322
|
+
export async function requireAuth(request: Request) {
|
|
323
|
+
const token = request.headers.get("Authorization")?.replace("Bearer ", "");
|
|
324
|
+
|
|
325
|
+
if (!token) {
|
|
326
|
+
throw new Response(JSON.stringify({ error: "Unauthorized" }), {
|
|
327
|
+
status: 401,
|
|
328
|
+
headers: { "Content-Type": "application/json" },
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
// Verify token...
|
|
333
|
+
return { userId: "123" };
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
// app/api/protected+api.ts
|
|
337
|
+
import { requireAuth } from "../../utils/auth";
|
|
338
|
+
|
|
339
|
+
export async function GET(request: Request) {
|
|
340
|
+
const { userId } = await requireAuth(request);
|
|
341
|
+
return Response.json({ userId });
|
|
342
|
+
}
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
### Proxy External API
|
|
346
|
+
|
|
347
|
+
```ts
|
|
348
|
+
// app/api/weather+api.ts
|
|
349
|
+
export async function GET(request: Request) {
|
|
350
|
+
const url = new URL(request.url);
|
|
351
|
+
const city = url.searchParams.get("city");
|
|
352
|
+
|
|
353
|
+
const response = await fetch(
|
|
354
|
+
`https://api.weather.com/v1/current?city=${city}&key=${process.env.WEATHER_API_KEY}`
|
|
355
|
+
);
|
|
356
|
+
|
|
357
|
+
return Response.json(await response.json());
|
|
358
|
+
}
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
## Rules
|
|
362
|
+
|
|
363
|
+
- NEVER expose API keys or secrets in client code
|
|
364
|
+
- ALWAYS validate and sanitize user input
|
|
365
|
+
- Use proper HTTP status codes (200, 201, 400, 401, 404, 500)
|
|
366
|
+
- Handle errors gracefully with try/catch
|
|
367
|
+
- Keep API routes focused — one responsibility per endpoint
|
|
368
|
+
- Use TypeScript for type safety
|
|
369
|
+
- Log errors server-side for debugging
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: expo-brownfield
|
|
3
|
+
description: Integrate Expo and React Native into an existing native iOS or Android app. Use when the user mentions brownfield, embedding React Native in a native app, AAR/XCFramework, or adding Expo to an existing Kotlin/Swift project. Covers both the isolated approach and the integrated approach.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Expo Brownfield
|
|
7
|
+
|
|
8
|
+
A **brownfield** app is an existing native iOS or Android app that adopts React Native incrementally, as opposed to a **greenfield** app that is React Native from day one.
|
|
9
|
+
|
|
10
|
+
Expo supports two distinct ways to add React Native to a brownfield project:
|
|
11
|
+
|
|
12
|
+
| Approach | What ships to the native app | When to choose |
|
|
13
|
+
| -------------- | ------------------------------------------------------------------- | -------------------------------------------------------------------------------- |
|
|
14
|
+
| **Isolated** | Prebuilt AAR / XCFramework | Native team doesn't need Node or RN tooling; RN code can live in a separate repo |
|
|
15
|
+
| **Integrated** | React Native sources added to the existing Gradle / CocoaPods build | One team owns everything; comfortable with RN tooling; wants a single build |
|
|
16
|
+
|
|
17
|
+
For the full decision matrix, see [./references/comparison.md](./references/comparison.md).
|
|
18
|
+
|
|
19
|
+
## Pick an approach
|
|
20
|
+
|
|
21
|
+
Use these quick rules — fall through to `comparison.md` for anything ambiguous.
|
|
22
|
+
|
|
23
|
+
- **Choose isolated** if the iOS/Android team must consume RN as a regular library dependency (AAR or XCFramework), without installing Node, Yarn, or the React Native build toolchain.
|
|
24
|
+
- **Choose isolated** if RN code and native code live in separate repositories or release on independent cadences.
|
|
25
|
+
- **Choose integrated** if a single team owns both the native and RN code and is willing to add React Native + Expo to the native project's Gradle and CocoaPods setup.
|
|
26
|
+
- **Choose integrated** if you want hot reload and JS source maps to work seamlessly inside the existing native build process.
|
|
27
|
+
|
|
28
|
+
## References
|
|
29
|
+
|
|
30
|
+
- ./references/brownfield-isolated.md -- Build RN as AAR/XCFramework and consume from the native app (BrownfieldActivity, ReactNativeViewController, ReactNativeView)
|
|
31
|
+
- ./references/brownfield-integrated.md -- Add RN and Expo directly to existing Gradle and CocoaPods builds (ReactActivity, RCTRootView, Podfile)
|
|
32
|
+
- ./references/comparison.md -- Decision criteria, trade-offs, and scenario mapping for choosing an approach
|
|
33
|
+
- ./references/troubleshooting.md -- Metro connection, build, signing, and module-resolution issues common to both approaches
|
|
34
|
+
|
|
35
|
+
More information available at https://docs.expo.dev/brownfield/overview/
|
|
36
|
+
|
|
37
|
+
## Shared prerequisites
|
|
38
|
+
|
|
39
|
+
Both approaches require, in the environment that _builds_ the React Native side:
|
|
40
|
+
|
|
41
|
+
- **Node.js (LTS)** — runs the Expo CLI and JavaScript code.
|
|
42
|
+
- **Yarn** — manages JavaScript dependencies.
|
|
43
|
+
|
|
44
|
+
The integrated approach additionally requires **CocoaPods** on iOS (`sudo gem install cocoapods`). The isolated approach does **not** require CocoaPods or any RN tooling in the consuming native app.
|
|
45
|
+
|
|
46
|
+
## Versioning note
|
|
47
|
+
|
|
48
|
+
**Expo SDK 55 is the minimum supported version for brownfield integration.** Earlier SDKs lack `expo-brownfield`, the required `ExpoReactHostFactory` / `ExpoReactNativeFactory` entry points, and the current autolinking surface. When creating the Expo project, always pin the SDK explicitly:
|
|
49
|
+
|
|
50
|
+
```sh
|
|
51
|
+
npx create-expo-app@latest my-project --template default@sdk-55
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Pin the same Expo SDK across both the RN project and any embedded dependencies.
|