Learn how to use the root layout to add global providers to your app when using Expo Router.
Traditional React Native projects are structured with a single root component that is often defined in ./App.js or ./index.js. This pattern is often used to inject global providers such as Redux, Themes, Styles, and so on, into the app, and to delay rendering until assets and fonts are loaded.
In Expo Router, you can use the Root Layout (app/_layout.js) to add providers which can be accessed by any route in the app.
Try to reduce the scope of your providers to only the routes that need them. This will improve performance and cause fewer rerenders.