--- title: Drawer Navigator impact: HIGH tags: react-navigation, drawer, sidebar, master-detail, header, responsive-layout --- # Skill: Drawer Navigator ## Description Use `createDrawerNavigator` for a navigation drawer or sidebar that switches between app sections. If using a drawer for displaying content instead of navigation, use [`react-native-drawer-layout`](https://reactnavigation.org/docs/drawer-layout/) instead. ## When to Use - Building app sections behind a drawer or sidebar - Showing a permanent sidebar on larger screens and a drawer on smaller screens - Using the drawer as the master pane in a master-detail layout ## Prerequisites Install and configure `react-native-gesture-handler`, `react-native-reanimated`, and `react-native-worklets` for drawer navigator to work on native platforms. ## Basic Example **Static API** ```tsx import { createDrawerNavigator } from '@react-navigation/drawer'; const AppDrawer = createDrawerNavigator({ screens: { Home: HomeScreen, Profile: ProfileScreen, }, }); ``` **Dynamic API** ```tsx import { createDrawerNavigator } from '@react-navigation/drawer'; const Drawer = createDrawerNavigator(); function AppDrawer() { return ( ); } ``` ## Opening and Closing the Drawer Use `navigation.openDrawer()`, `navigation.closeDrawer()`, and `navigation.toggleDrawer()` inside drawer screens to open or close the drawer programmatically. ```tsx import { Button, View } from 'react-native'; import { useNavigation } from '@react-navigation/native'; function HomeScreen() { const navigation = useNavigation(); return (