When developing a mobile application using React Native, navigation is a critical component of the user experience. One common navigation type is a Drawer Navigation, which allows the user to get between screens showing the user-specific areas of the application from a side panel that slides out on the left or right.

What is Drawer Navigation?
Drawer navigation, more frequently referred to as the slide-in menu or hamburger menu, is a UI pattern that allows users to view their navigation options from a panel that slides out from the edge of the screen. This methodology is widely used in applications and enables the user to navigate through varying parts of an app in an organised and clean way. Some vital areas are the drawer’s appearance (slide, front or back, permanent), drawer position (left or right), and any customizable aspects for the drawer’s appearance or functionality.
How to Implement Drawer Navigation in a React Native App?
Step 1: Installation
Install the necessary packages:
npm install @react-navigation/native @react-navigation/drawer react-native-reanimated react-native-gesture-handler react-native-screens react-native-safe-area-context
For iOS, navigate to your ios directory and run:
pod install
Step 2: Configure react-native-reanimated
Add the Reanimated plugin to your babel.config.js:
module.exports = {
presets: ['module:@react-native/babel-preset'],
plugins: ['react-native-reanimated/plugin'],
};
Step 3: Import Gesture Handler
Ensure react-native-gesture-handler is imported at the very top of your entry file
(e.g., index.js or App.js):
import 'react-native-gesture-handler';
Step 4: Create Drawer Navigator
In your App.js or a dedicated navigation file:
import * as React from 'react';
import { NavigationContainer } from '@react-navigation/native';
import { createDrawerNavigator } from '@react-navigation/drawer';
import HomeScreen from './screens/HomeScreen';
import SettingsScreen from './screens/SettingsScreen';
const Drawer = createDrawerNavigator();
function App() {
return (
<NavigationContainer>
<Drawer.Navigator initialRouteName="Home">
<Drawer.Screen name="Home" component={HomeScreen} />
<Drawer.Screen name="Settings" component={SettingsScreen} />
</Drawer.Navigator>
</NavigationContainer>
);
}
export default App;
Step 5: Create Screen Components
Create your screen components (e.g., HomeScreen.js, SettingsScreen.js) with basic Views.
function HomeScreen() {
return (
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
<Text>🏠 Home Screen</Text>
</View>
);
}
function SettingsScreen() {
return (
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
<Text>👤 SettingsScreen</Text>
</View>
);
}
Step 6: Customizing the Drawer
You can customize the drawer’s appearance and behavior using various props on the Drawer.Navigator and Drawer.Screen, such as drawerContent for a custom drawer component, drawerPosition, drawerType, and styling options like drawerStyle.
Conclusion:
This setup provides a functional drawer navigation that can be opened by swiping from the edge or using a navigation menu icon.
FAQ
- What is Drawer Navigation in React Native?
Drawer Navigation is a navigation pattern where a menu (drawer) slides in from the left/right of the page, generally to contain links to different screens or functionality in your application.
- Why use drawer navigation in a React Native app?
Drawer Navigation is a way to organize the layout of your application, and access content or page options from anywhere in your application. This is especially useful when you have an app with multiple sections.
- Which library is commonly used for drawer navigation in React Native?
The most commonly used and the most widely used library to implement drawer navigation in React Native is React Navigation (@react-navigation/drawer).