|
| 1 | +--- |
| 2 | +title: "Expo App" |
| 3 | +description: "Expo web app running in the sandbox using Node.js" |
| 4 | +--- |
| 5 | + |
| 6 | +Basic Expo app. |
| 7 | + |
| 8 | +<Note> |
| 9 | + The development server runs on port 8081 as soon as the sandbox is ready. |
| 10 | +</Note> |
| 11 | + |
| 12 | +<CodeGroup> |
| 13 | +```typescript JavaScript & TypeScript |
| 14 | +// template.ts |
| 15 | +import { defaultBuildLogger, waitForURL } from "e2b"; |
| 16 | + |
| 17 | +export const template = Template() |
| 18 | + .fromNodeImage() |
| 19 | + .setWorkdir("/home/user/expo-app") |
| 20 | + .runCmd("npx create-expo-app@latest . --yes") |
| 21 | + .runCmd("mv /home/user/expo-app/* /home/user/ && rm -rf /home/user/expo-app") |
| 22 | + .setWorkdir("/home/user") |
| 23 | + .setStartCmd("npx expo start", waitForURL("http://localhost:8081")); |
| 24 | +``` |
| 25 | + |
| 26 | +```python Python |
| 27 | +# template.py |
| 28 | +from e2b import Template, wait_for_url |
| 29 | + |
| 30 | +template = ( |
| 31 | + Template() |
| 32 | + .from_node_image() |
| 33 | + .set_workdir("/home/user/expo-app") |
| 34 | + .run_cmd("npx create-expo-app@latest . --yes") |
| 35 | + .run_cmd("mv /home/user/expo-app/* /home/user/ && rm -rf /home/user/expo-app") |
| 36 | + .set_workdir("/home/user") |
| 37 | + .set_start_cmd("npx expo start", wait_for_url('http://localhost:8081')) |
| 38 | +) |
| 39 | +``` |
| 40 | +</CodeGroup> |
| 41 | + |
| 42 | +<CodeGroup> |
| 43 | +```typescript JavaScript & TypeScript |
| 44 | +// build.ts |
| 45 | +import { Template, defaultBuildLogger } from 'e2b' |
| 46 | +import { template as expoTemplate } from './template' |
| 47 | + |
| 48 | +Template.build(expoTemplate, { |
| 49 | + alias: 'expo-app', |
| 50 | + cpuCount: 4, |
| 51 | + memoryMB: 8192, |
| 52 | + onBuildLogs: defaultBuildLogger(), |
| 53 | +}) |
| 54 | +``` |
| 55 | + |
| 56 | +```python Python |
| 57 | +# build.py |
| 58 | +from e2b import Template, default_build_logger |
| 59 | +from .template import template as expoTemplate |
| 60 | + |
| 61 | +Template.build(expoTemplate, |
| 62 | + alias="expo-app", |
| 63 | + cpu_count=4, |
| 64 | + memory_mb=8192, |
| 65 | + on_build_logs=default_build_logger(), |
| 66 | +) |
| 67 | +``` |
| 68 | +</CodeGroup> |
0 commit comments