Cours React Native · Module 1: Ta première application

Créer ton premier projet Expo

4 min de lecture ·
Dans cette leçon5

Il est temps de créer ton premier projet en Atlantide ! Nous utiliserons la dernière version d'Expo avec Expo Router.

Créer le projet

Ouvre un terminal et exécute :

# Créer un nouveau projet avec un template
npx create-expo-app@latest AtlantisApp

# Se placer dans le dossier du projet
cd AtlantisApp

Expo te demandera un template - choisis « blank (TypeScript) » pour un projet propre.

Ou alors avec Expo Router (recommandé) :

npx create-expo-app@latest AtlantisApp --template tabs

cd AtlantisApp

Structure du projet

Après avoir créé le projet, tu verras :

AtlantisApp/
├── app/                    # App screens (Expo Router)
│   ├── (tabs)/            # Tab navigation group
│   │   ├── index.tsx      # First tab (Home)
│   │   ├── explore.tsx    # Second tab (Explore)
│   │   └── _layout.tsx    # Layout for tabs
│   ├── _layout.tsx        # Main app layout
│   └── +not-found.tsx     # 404 screen
├── assets/                 # Images, fonts, icons
│   ├── images/
│   └── fonts/
├── components/            # Reusable components
├── constants/             # Constants (colors, dimensions)
├── hooks/                 # Custom hooks
├── app.json              # Expo configuration
├── package.json          # Dependencies
├── tsconfig.json         # TypeScript configuration
└── babel.config.js       # Babel configuration

Dans le modèle depuis Expo SDK 55, les écrans se trouvent dans src/app/ au lieu d'un dossier app/ à la racine. Expo Router prend en charge les deux emplacements.

Lancer le projet

# Démarrer le serveur de développement
npx expo start

Tu verras :

› Metro waiting on exp://192.168.1.100:8081
› Scan the QR code above with Expo Go (Android) or the Camera app (iOS)

› Using Expo Go
› Press s │ switch to development build
› Press a │ open Android
› Press i │ open iOS simulator
› Press w │ open web
› Press r │ reload app
› Press m │ toggle menu
› Press ? │ show all commands

Tester sur ton téléphone

  1. Installe Expo Go depuis l'App Store ou Google Play
  2. Scanne le QR code depuis le terminal
  3. L'application se lancera sur ton téléphone !

Tester sur un émulateur

# Android (nécessite Android Studio)
npx expo start --android

# iOS (macOS uniquement, nécessite Xcode)
npx expo start --ios

# Web (navigateur)
npx expo start --web

Le fichier app.json - Configuration de l'application

{
  "expo": {
    "name": "AtlantisApp",
    "slug": "atlantis-app",
    "version": "1.0.0",
    "orientation": "portrait",
    "icon": "./assets/images/icon.png",
    "scheme": "atlantisapp",
    "userInterfaceStyle": "automatic",
    "splash": {
      "image": "./assets/images/splash.png",
      "resizeMode": "contain",
      "backgroundColor": "#1a5276"
    },
    "ios": {
      "supportsTablet": true,
      "bundleIdentifier": "com.yourname.atlantisapp"
    },
    "android": {
      "adaptiveIcon": {
        "foregroundImage": "./assets/images/adaptive-icon.png",
        "backgroundColor": "#1a5276"
      },
      "package": "com.yourname.atlantisapp"
    },
    "web": {
      "bundler": "metro",
      "output": "static",
      "favicon": "./assets/images/favicon.png"
    },
    "plugins": ["expo-router"]
  }
}

Les options les plus importantes :

OptionDescription
nameNom affiché à l'écran
slugNom d'URL unique du projet
versionVersion de l'application
iconIcône de l'application (1024x1024px)
splashÉcran de chargement
ios.bundleIdentifierID pour l'App Store
android.packageID pour Google Play

Hot Reload - Changements instantanés

Expo prend en charge le Fast Refresh - les modifications du code sont visibles immédiatement sans recharger toute l'application !

Modifie app/(tabs)/index.tsx :

import { Text, View, StyleSheet } from 'react-native';

export default function HomeScreen() {
  return (
    <View style={styles.container}>
      <Text style={styles.title}>Bienvenue en Atlantide !</Text>
      <Text style={styles.subtitle}>Ta première application Expo</Text>
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#1a5276',
  },
  title: {
    fontSize: 28,
    fontWeight: 'bold',
    color: '#fff',
    marginBottom: 10,
  },
  subtitle: {
    fontSize: 16,
    color: '#aed6f1',
  },
});

Enregistre le fichier - les changements apparaîtront instantanément !

Tu as repéré une erreur dans cette leçon ?

Teste tes connaissances

Réponds aux questions de cette leçon. Choisis une réponse pour voir tout de suite si elle est correcte.

  1. 1. Dans quel dossier se trouvent les écrans de l'application lorsqu'on utilise Expo Router ?

  2. 2. Quel fichier contient la configuration de l'application Expo (nom, icône, splash screen) ?

  1. QuestionQuiz : Structure d'un projet Expo
  2. QuestionQuiz : Fichier de configuration

Articles utiles