An introduction to config plugins for the Expo project.
An automatic setup for adding a native module to your project is possible. Sometimes, a module requires a more complex setup. A config plugin can be used to automatically configure your native project for a module and reduce the complexity by avoiding interaction with the native project.
Config plugin is a system for extending the app config and customizing the prebuild process for your app. They can be used to add native modules that aren't included, by default, or to add any native code that needs to be configured further.
Internally Expo CLI uses config plugins to generate and configure all the native code for a managed project. Plugins do things such as generate app icons, set the app name, and configure the AndroidManifest.xml, Info.plist, and so on.
You can think of plugins like a bundler for native projects, and running
npx expo prebuild as a way to bundle the projects by evaluating all the project plugins. Doing so will generate android and ios directories. These directories can be modified manually after being generated, but then they can no longer be safely regenerated without potentially overwriting manual modifications.
Expo config plugins mostly come from Node.js modules. You can install them just like other packages in your project.
expo-camera has a plugin that adds camera permissions to the AndroidManifest.xml and Info.plist. To install it in your project, run the following command:
npx expo install expo-camera
In your app's config (app.json, or app.config.js), you can add
expo-camera to the list of plugins:
Some plugins such as for
expo-camera can be customized by passing an array, where the second argument is the options:
"cameraPermission": "Allow $(PRODUCT_NAME) to access your camera."
For each Expo package that a config plugin is available for, you'll find more information about that in the package's API reference.
On running the
npx expo prebuild, the
mods are compiled, and the native files change.
The changes don't take effect until you rebuild the native project, for example, with Xcode. If you're using config plugins in a managed app,
they will be applied during the prebuild phase on