Extending Native Capabilities with Expo Config Plugins
Learn how to add custom native code to an Expo‑managed app using Config Plugins, avoiding the need to eject while keeping OTA updates intact.
Insight
Expo Config Plugins let you inject native changes—like permissions, Gradle tweaks, or Info.plist entries—directly from app.json/app.config.js. The plugin runs during the pre‑build step, so your managed workflow stays intact and OTA updates remain possible. This approach bridges the gap between pure managed apps and fully ejected projects, giving you the best of both worlds.
Example
// plugins/addCameraPermission.ts
import { ConfigPlugin, AndroidManifest } from '@expo/config-plugins';
const withCameraPermission: ConfigPlugin = (config) => {
return AndroidManifest.withAndroidManifest(config, (manifest) => {
manifest.manifest['uses-permission'] = [
...(manifest.manifest['uses-permission'] || []),
{ $: { 'android:name': 'android.permission.CAMERA' } },
];
return manifest;
});
};
export default withCameraPermission;
Add the plugin to app.config.js:
export default {
expo: {
name: 'MyApp',
plugins: ['./plugins/addCameraPermission'],
},
};
Takeaway
When you need a single native tweak, write a tiny Config Plugin instead of ejecting. It keeps your build pipeline simple, preserves OTA updates, and scales nicely across iOS and Android.