Requirements#
| Requirement | Version | Notes |
|---|---|---|
| Expo SDK | 57 | |
| React Native | 0.86 or later, New Architecture | |
| React | 19 | |
| Development build | required | Expo Go is not supported. It cannot load the native WebGPU module. |
| Web | optional | Expo web works. Scenes draw with WebGPU, or WebGL 2 where WebGPU isn't available. See On the web. |
| iOS | a device or the simulator | The config plugin turns off Metal API validation, which the simulator needs. |
| Android | 8.0+ (API 26) | The config plugin raises minSdkVersion for you. |
1. Install the packages#
A scene needs @apricotjs/react-native and @apricotjs/core, plus react-native-webgpu and three. @apricotjs/metro, @types/three and @webgpu/types are dev dependencies.
npx expo install @apricotjs/react-native @apricotjs/core react-native-webgpu three
npm install --save-dev @apricotjs/metro @types/three @webgpu/typesApricot ships TypeScript sources, and your type-check reads them. They need @types/three and @webgpu/types. tsconfig.json needs no change.
Install the optional packages only for the features that use them. If one is missing, Apricot still works, and a feature that needs it tells you what to install.
# Shared values in props, <Label> on the UI thread
npx expo install react-native-reanimated react-native-worklets
# Bundled models and textures, downloads, saved layouts, captureScene
npx expo install expo-asset expo-file-system
# Ready-made objects
npm install @apricotjs/assets| Package | Needed | Used for |
|---|---|---|
@apricotjs/react-native |
yes | Every component and hook. |
@apricotjs/core |
yes | The engine. Utilities such as seededRandom are imported from it. |
react-native-webgpu |
yes | The GPU canvas (Metal on iOS, Vulkan on Android). |
three |
yes, r186 | The 3D library Apricot uses. App code rarely imports it directly. |
@apricotjs/metro |
yes, as a dev dependency | withApricot() for Metro, and the apricot-models CLI. |
@types/three, @webgpu/types |
yes, as dev dependencies | Types for three.js and WebGPU, which Apricot's TypeScript sources use. |
@apricotjs/assets |
optional | Ready-made objects (MoneyStack, Apple, Car, Card…). |
react-native-reanimated, react-native-worklets |
optional | Shared values in any animatable prop, and <Label> moving on the UI thread. Without them, props take plain values and labels re-render as they move. |
expo-asset, expo-file-system |
optional (both come with Expo) | <Model> and textures from bundled files, keeping downloaded models and pictures on the phone (download), saved layouts in useLayout (unless you pass your own storage), and captureScene. |
react-native-gesture-handler |
optional | Not used by Apricot itself. The recipes use it for swipes, drags and the joystick. |
@gltf-transform/core, @gltf-transform/extensions, @gltf-transform/functions, draco3dgltf, meshoptimizer |
optional, dev | Only to run npx apricot-models. See Tooling. |
An app without an optional package still bundles and type-checks.
Tested with: expo 57.0.27, react-native 0.86.3, react 19.2.3, react-native-webgpu 0.12.1, three 0.186.1, react-native-reanimated 4.5.1, react-native-worklets 0.10.1, react-native-gesture-handler 2.32.0, @types/three 0.186.0, @webgpu/types 0.1.74.
2. Add the config plugin#
The config plugin sets up react-native-webgpu, raises Android minSdkVersion to at least 26, and lets iOS ProMotion screens run at 120 Hz.
module.exports = {
expo: {
name: "My App",
slug: "my-app",
plugins: ["@apricotjs/react-native"],
},
};With app.json, add "@apricotjs/react-native" to expo.plugins the same way.
3. Configure Metro#
withApricot lets Metro bundle .glb and .gltf files, and makes every three import resolve to one copy of three's WebGPU build.
const { getDefaultConfig } = require("expo/metro-config");
const { withApricot } = require("@apricotjs/metro");
module.exports = withApricot(getDefaultConfig(__dirname));4. Wrap the app for gestures (optional)#
If you use react-native-gesture-handler, as the recipes do, wrap the app root in GestureHandlerRootView. Taps, <CameraRig orbit> and <Placement> work without it.
import { Stack } from "expo-router";
import { GestureHandlerRootView } from "react-native-gesture-handler";
export default function Layout() {
return (
<GestureHandlerRootView style={{ flex: 1 }}>
<Stack />
</GestureHandlerRootView>
);
}Babel needs no change. babel-preset-expo adds the worklets plugin when Reanimated is installed.
5. Build and run#
Apricot adds native code, so build a development client.
npx expo prebuild
npx expo run:ios # or: npx expo run:androidFor later JavaScript changes, start Metro.
npx expo start --dev-client6. Check it works#
Render a scene on any screen.
import { Box, Scene, Spin } from "@apricotjs/react-native";
export default function Home() {
return (
<Scene style={{ flex: 1 }} debug>
<Spin speed={1}>
<Box size={1.6} color="#ff9f59" />
</Spin>
</Scene>
);
}You should see an orange cube turning on a cream background. debug adds a small HUD with fps, render and present times. For about the first second, the scene shows only its background. This is expected (see Scenes).
If something fails, see Troubleshooting.
Next#
- Quick start: build a scene step by step.
- Building with AI: rules for AI assistants writing Apricot code.
- Testing: set up Jest for screens that contain a scene.