Cours React Native · Module 1: Ta première application
Créer ton premier projet Expo
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 AtlantisAppExpo 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 AtlantisAppStructure 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 configurationDans 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 startTu 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 commandsTester sur ton téléphone
- Installe Expo Go depuis l'App Store ou Google Play
- Scanne le QR code depuis le terminal
- 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 --webLe 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 :
| Option | Description |
|---|---|
name | Nom affiché à l'écran |
slug | Nom d'URL unique du projet |
version | Version de l'application |
icon | Icône de l'application (1024x1024px) |
splash | Écran de chargement |
ios.bundleIdentifier | ID pour l'App Store |
android.package | ID 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. Dans quel dossier se trouvent les écrans de l'application lorsqu'on utilise Expo Router ?
2. Quel fichier contient la configuration de l'application Expo (nom, icône, splash screen) ?