Skip to main content

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

Use tailwindcss over the old theme system where possible! you can use theme colors in tailwind classes by replacing the underscores with dashes like: bg-primary-foreground and bg-primary Don’t import theme directly. Instead, use the useAppTheme hook:
Don’t create StyleSheets. Use themed styles instead:
Don’t use expo router’s navigation methods directly. Use the useNavigationHistory() hook:

Internationalization (i18n)

Use the tx prop for translations on Ignite components:
Define your strings in the appropriate language file (src/i18n/en.ts):
Use translate() for strings in code:

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, but also consider creating a new category

Component Structure

Import Guidelines

Import Order

  1. External dependencies (React, React Native, third-party packages)
  2. Internal absolute imports (@/ paths)
  3. 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!

Code rules and guidelines to follow

  • Strings should never be null or undefined unless you have a really good reason, (make them default to an empty string)
  • Avoid using the any type, and always reference types defined in the cloud when possible
This project contains custom native modules that must be preserved.

Additional Resources