Setup the Toaster component
mainThe Toaster is the central context component that manages toast notifications. To ensure it works correctly across all screens, you must render it at the root level of your app, after the NavigationContainer.
Crucial Requirement: The Toaster must be rendered within both a SafeAreaProvider and a GestureHandlerRootView.
import { Toaster } from 'sonner-native';
import { NavigationContainer } from '@react-navigation/native';
import { SafeAreaProvider } from 'react-native-safe-area-context';
import { GestureHandlerRootView } from 'react-native-gesture-handler';
export default function App() {
return (
<SafeAreaProvider>
<GestureHandlerRootView>
<NavigationContainer>{/* App content */}</NavigationContainer>
<Toaster />
</GestureHandlerRootView>
</SafeAreaProvider>
);
}