Skip to Content
ConventionsNaming Conventions

Naming Conventions

Consistent naming makes the codebase navigable at a glance. Every file, function, type, and constant follows a predictable pattern.

Files and Directories

ItemConventionExample
Component directoryPascalCasesrc/common/components/Button/
Component filePascalCase.tsxButton.tsx
Component stylesPascalCase.styles.tsButton.styles.ts
Component typesPascalCase.types.tsButton.types.ts
Component barrellowercaseindex.ts
Hook filecamelCase, starts with useuseBottomPadding.ts
Store filecamelCase, ends with StoreauthStore.ts
Service filecamelCase, ends with ServiceauthService.ts
Schema filecamelCase, ends with SchemaloginSchema.ts
Screen file (app/)lowercase with hyphensforgot-password.tsx
Layout file (app/)underscore prefix_layout.tsx
Constants filecamelCaseconstants.ts
i18n locale fileslowercaseen.json, ar.json

Components

Component names are always PascalCase. Props interfaces are named {ComponentName}Props.

// src/common/components/UserCard/UserCard.tsx import type { UserCardProps } from './UserCard.types'; export function UserCard({ name, avatar }: UserCardProps) { // ... }
// src/common/components/UserCard/UserCard.types.ts export interface UserCardProps { name: string; avatar?: string; }

Export Rules

Named exports for everything in src/. Default exports only for screen files in app/.

// CORRECT -- named export in src/ export function Button({ title, onPress }: ButtonProps) { /* ... */ } // CORRECT -- default export in app/ screen files export default function HomeScreen() { /* ... */ }
// WRONG -- default export from a component in src/ export default function Button() { /* ... */ }

Expo Router requires default exports for screen files in the app/ directory. This is the only place where default exports are used.

Hooks

  • Always start with use: useAuthStore, useNetworkStatus, useBottomPadding
  • File names match the exported hook: useNetworkStatus.ts
  • Return objects (not arrays), unless it is a classic two-element state tuple
// CORRECT -- returns a named object export function useScreenDimensions() { return { width, height, isLandscape }; } // WRONG -- unnamed array from a custom hook export function useScreenDimensions() { return [width, height]; }

Stores

Zustand stores are exported as hooks with the use prefix and the Store suffix.

ItemConventionExample
Store hookuse{Feature}StoreuseAuthStore
State interface{Feature}StateAuthState
File name{feature}Store.tsauthStore.ts

TypeScript Types and Interfaces

  • Interfaces for object shapes: interface ButtonProps
  • Type aliases for unions, primitives, and mapped types: type ButtonVariant = 'primary' | 'secondary'
  • All type-only imports use the type keyword:
import type { ButtonProps } from './Button.types'; import type { User } from '@/types';

No any types. Use unknown and narrow, or define a proper type.

Constants

KindConventionExample
True constantsSCREAMING_SNAKE_CASESTORAGE_KEYS, AVATAR_SIZES
Config objectscamelCasebreakpoints, spacing
Last updated on