MentraOS Mobile App Development Guidelines
This guide provides coding standards and best practices for contributing to MentraOS Mobile App, the React Native mobile app component of the MentraOS ecosystem.Architecture Overview
MentraOS Mobile App is a React Native app built with:- Expo for development tooling and managed workflow
- expo-router for file-based routing
- React Context API for state management
- TypeScript for type safety
Code Style Guidelines
Theme and Styling
Don’t importtheme
directly. Instead, use the useAppTheme
hook:
Navigation
Don’t use expo router’s navigation methods directly. Use theuseNavigationHistory()
hook:
Internationalization (i18n)
Use the tx prop for translations on Ignite components:src/i18n/en.ts
):
Project Structure
Component Guidelines
File Organization
- Place screen components in
src/app/
following the routing structure - Organize reusable components in
src/components/
by feature - Use
misc/
folder for components that don’t fit a specific category
Component Structure
Import Guidelines
Import Order
- External dependencies (React, React Native, third-party packages)
- Internal absolute imports (@/ paths)
- Relative imports (if necessary)
Example
Best Practices
Error Handling
Always wrap async operations in try-catch blocks with meaningful error messages:Performance
- Use React.memo for expensive components
- Leverage useMemo and useCallback for expensive computations
- Avoid inline styles and functions in render
Type Safety
- Always define proper TypeScript types
- Avoid using
any
type - Use strict null checks
Testing
Run tests with:Linting and Type Checking
Before committing:Native Development
Important: Prebuild Warning
Never use--clean
or --clear
flags with expo prebuild!