Expo template
This template installs pinned Expo 57, React, and React Native versions. Metro starts in offline mode on port 8081 and becomes part of the ready sandbox state.
mjs
import { Sandbox, Template, waitForURL } from "@abox-dev/sdk";
const templateName = process.env.TEMPLATE_NAME ?? "expo-app";
const template = Template({ fileContextPath: "." })
.fromNodeImage("24-bookworm-slim")
.setWorkdir("/home/user/app")
.copy("package.json", "/home/user/app/package.json")
.copy("App.js", "/home/user/app/App.js")
.runCmd("npm install")
.setEnvs({ CI: "1" })
.setStartCmd(
"npm run start -- --offline --port 8081",
waitForURL("http://localhost:8081"),
);
await Template.build(template, templateName, {
cpuCount: 2,
memoryMB: 2_048,
});
const sandbox = await Sandbox.create(templateName);
try {
const response = await sandbox.commands.run(
"curl --silent --head http://localhost:8081 | head -n 1",
);
console.log(response.stdout);
} finally {
await sandbox.kill();
}Keep package.json and App.js next to the example. The CI variable is set during the build because that is when the start command runs.
This template prepares the Metro server. Add the required dependencies and an appropriate Expo client for Android, iOS, or web development.