Comprehensive instructions for building Expo apps using gluestack-ui.
This document defines the skill set and operational guidelines for AI agents working on this project. The primary goal is to build high-quality, visually appealing mobile applications using Expo and gluestack-ui.
When starting a new project or setting up the environment, the agent must follow these steps:
Use the latest Expo template:
npx create-expo-app@latest my-app --template default
cd my-app
Follow the official installation guide to integrate gluestack-ui:
Initialize gluestack-ui:
npx gluestack-ui init
GluestackUIProvider.components folder for your UI components.Wrap Application Root:
Ensure the root layout (e.g., app/_layout.tsx or App.tsx) is wrapped with the provider:
import { GluestackUIProvider } from "@/components/ui/gluestack-ui-provider";
import "@/global.css"; // If using NativeWind or global styles
export default function Layout() {
return (
<GluestackUIProvider>
<Slot /> {/* or your main app content */}
</GluestackUIProvider>
);
}
gluestack-ui is unstyled by default and headless, meaning you add components as you need them.
NEVER try to import a component that hasn't been added to the project. Always check the components/ui directory first.
To add a new component (e.g., Button, Box, Text):
npx gluestack-ui add [component-name]
# Example:
npx gluestack-ui add button box text
Agent Note: If a user asks for a UI element, identify the corresponding gluestack component, run the add command if it's missing, and then implement it.
Box, VStack, HStack, Center for layout instead of raw View styles.<VStack space="md" reversed={false}>
<Box className="w-20 h-20 bg-primary-500" />
</VStack>
Text and Heading with size props.Button, Pressable, Link.$2, $4, md, lg).<Box w="$full" md-w="$1/2"> (Full width on mobile, half width on medium screens/tablets).space prop in stacks or padding props).import { useForm, Controller } from "react-hook-form";
import { zodResolver } from "@hookform/resolvers/zod";
// ... define z.object schema ...
lucide-react-native).import { Camera } from "lucide-react-native";
import { Icon } from "@/components/ui/icon";
// Usage: <Icon as={Camera} size="md" />
app/_layout.tsx: Root provider setup (gluestack, query client).app/(tabs): For tab-based navigation.app/[id].tsx: For dynamic routes.Link from expo-router for web-compatible navigation.File Structure:
app/ (if using Expo Router).components/.hooks/ or utils/.Code Style:
useState, useEffect) appropriately.Error Handling:
npx gluestack-ui add), if they fail, analyze the error (e.g., missing peer dependencies) and fix it before proceeding.Dependency Management:
npx expo install [package-name] instead of npm install or yarn add when possible, as this ensures the installed version is compatible with the project's Expo SDK version.When assigned a task to build a screen:
components/ui; if not, run npx gluestack-ui add ....VStack/HStack for layout.To enhance capability, the agent should leverage established skill sets from industry leaders:
upgrading-expo: When moving between Expo SDK versions.expo-deployment: For setting up EAS Build and Submit.expo-app-design: General Expo app architecture guidance.