Skip to main content

Requiring Hardware Features with Expo


iOS and Android allow you to specify specific hardware that your app needs in order to be able to run. When users go to download your app from the respective app stores, if their device doesn't meet this hardware requirement, the store will not allow the user to download the app to that device.

For this recipe, we're going to be creating an expo config plugin to add the required properties to our app's prebuild system so that users with devices that DO NOT have a front-facing camera or a microphone won't be able to download our app.

We'll get started by igniting a new application with the cng workflow.

npx ignite-cli new PizzaApp --workflow=cng --yes
cd PizzaApp

Add the plugin file

Create a new file called plugins/withRequiredHardware.ts and put the following content in it.

You can see that we've defined every possible value for iOS and Android.

import {
type ConfigPlugin,
type AndroidConfig,
type IOSConfig,
} from "@expo/config-plugins"

// More info:
const validAndroidFeatures = [
] as const

// More info:
const validIOSFeatures = [
] as const

type HardwareFeatureAndroid = (typeof validAndroidFeatures)[number]
type HardwareFeatureIOS = (typeof validIOSFeatures)[number]

export const withRequiredHardware: ConfigPlugin<{
ios: Array<HardwareFeatureIOS>
android: Array<HardwareFeatureAndroid>
}> = (config, { android, ios }) => {
// Add android required hardware
config = withAndroidManifest(config, (config) => {
config.modResults = addHardwareFeaturesToAndroidManifestManifest(config.modResults, android)
return config

// Add ios required hardware
config = withInfoPlist(config, (config) => {
config.modResults = addRequiredDeviceCapabilitiesToInfoPlist(config.modResults, ios)
return config

return config

export function addHardwareFeaturesToAndroidManifestManifest(
androidManifest: AndroidConfig.Manifest.AndroidManifest,
requiredFeatures: Array<HardwareFeatureAndroid>,
) {
// Add `<uses-feature android:name="" android:required="true"/>` to the AndroidManifest.xml
if (!Array.isArray(androidManifest.manifest["uses-feature"])) {
androidManifest.manifest["uses-feature"] = []

// Here we add the feature to the manifest:
// loop through the array of features and add them to the manifest if they don't exist
for (const feature of requiredFeatures) {
if (
!androidManifest.manifest["uses-feature"].find((item) => item.$["android:name"] === feature)
) {
$: {
"android:name": feature,
"android:required": "true",

return androidManifest

export function addRequiredDeviceCapabilitiesToInfoPlist(
infoPlist: IOSConfig.InfoPlist,
requiredFeatures: Array<HardwareFeatureIOS>,
) {
if (!infoPlist.UIRequiredDeviceCapabilities) {
infoPlist.UIRequiredDeviceCapabilities = []
const existingFeatures = infoPlist.UIRequiredDeviceCapabilities as Array<HardwareFeatureIOS>
for (const f of requiredFeatures) {
if (!existingFeatures.includes(f)) {

infoPlist.UIRequiredDeviceCapabilities = existingFeatures
return infoPlist

Enable the plugin

To enable the new plugin, open the app.config.ts file and where you see plugins: add the new plugin:

  return {
plugins: [
// More info:
ios: ["front-facing-camera", "microphone"],
// More info:
android: ["", "android.hardware.microphone"],

Note that this plugin is an array. The first element of the array is the plugin and the second is an object representing the required hardware you want for both iOS and Android.

Check that your install worked

Now run yarn prebuild:clean and then check that the following files have the changes yous specified in the plugin configuration:

For iOS:

In ./ios/[ProjectName]/Info.plist:

You should see new entries in the UIRequiredDeviceCapabilities array:


For Android:

In ./android/app/src/main/AndroidManifest.xml

You should see new <uses-feature entries corresponding to the configuration:

<uses-feature android:name="" android:required="true"/>
<uses-feature android:name="android.hardware.microphone" android:required="true"/>

And that's it!

When you publish your app to both app stores, the new hardware requirements will prevent users from downloading your app if their device doesn't meet these specifications.

Is this page still up to date? Did it work for you?