UIR

Expo

Install and configure UIR for Expo.

Use the CLI

Create project

Run init with the expo template. It creates a new Expo app and sets up UIR inside it.

npx @codewithrabby/ui@latest init -t expo

Add components

npx @codewithrabby/ui@latest add image-stack

Then import it from your components folder:

src/app/index.tsx
import { ImageStack } from "@/components/uir/image-stack";

export default function Screen() {
  return (
    <ImageStack images={[require("./back.jpg"), require("./front.jpg")]} />
  );
}

Existing Project

Run init

In the root of your Expo app:

npx @codewithrabby/ui@latest init

You'll be asked where components should go. This is saved in uir.json:

uir.json
{
  "$schema": "https://ui.codewithrabby.com/schema.json",
  "framework": "expo",
  "componentsDir": "src/components/uir",
  "alias": "@/components/uir"
}

init also installs react-native-reanimated, react-native-gesture-handler, react-native-worklets and react-native-svg with expo install.

Wrap your root layout

Gesture components need GestureHandlerRootView at the root of your app. The CLI reminds you if it's missing.

src/app/_layout.tsx
import { Stack } from "expo-router";
import { GestureHandlerRootView } from "react-native-gesture-handler";

export default function RootLayout() {
  return (
    <GestureHandlerRootView style={{ flex: 1 }}>
      <Stack />
    </GestureHandlerRootView>
  );
}

Check your import alias

New Expo apps already map @/* to src/* in tsconfig.json. If yours doesn't, add it:

tsconfig.json
{
  "compilerOptions": {
    "paths": {
      "@/*": ["./src/*"]
    }
  }
}

Add components

npx @codewithrabby/ui@latest add image-stack