React Native enables developers to build native apps for Amazon Fire OS devices using their existing JavaScript and React skills. Since Fire OS is based on the Android Open Source Project (AOSP), if you are already working with React Native you can easily target our devices without learning a new tech stack or maintaining separate codebases.
We recommend using the Expo framework to build React Native apps as it enables an easier and faster development experience. Follow along to see how to get up and running with React Native for both Fire Tablets and Fire TVs.
✅ Pre-requisites for this guide
Install the following:
Node.js: The JavaScript runtime environment
npm or Yarn: Package managers for JavaScript
Android Studio: the IDE used to compile and run your Fire OS apps locally
Configure Android Studio and its command-line tools:
Follow this guide to set your ANDROID_HOME environment variable
Install the following emulators from Android Studio’s virtual device manager:
For Tablet:
For TV:
📱 Building for Fire Tablets
In the terminal, create a new React Native project with the expo package installed:
Running on Fire Tablet Emulator
List the available avds then launch the Android Tablet:
emulator -avd name-of-your-tablet-emulator
Navigate to the project directory (e.g. FireTabletDemo) and run the app using npx:
npx expo start -a
Your app is now running on the emulator using a local development server and Expo Go, without having to create the Android build.
Running on a physical tablet device:
Follow the instructions here to connect your tablet via adb. Afterwards, confirm it is available as a device:
Navigate to the project directory then run a development build on your target device (e.g. KFTRWI)
npx expo run:android -d [deviceName]
The development build will now install within the android directory:
📺 Building for Fire TVs
To build apps for Fire TVs with React Native you can follow a similar journey.
In a new directory, create a new React Native project with the expo, this time using the with-tv example:
Running on Android TV Emulator
Launch the Android TV emulator:
Navigate to the project directory and run your app:
npx expo start -a
Similar to the Fire tablets, your app will run on the avd emulator without having to create the Android build:
Target the build for TVs:
In order to build for TVs, set the isTV prop to true in your app.json:
“expo”: {
“plugins”: [
[
“@react-native-tvos/config-tv”,
{
“isTV”: true,
}
]
],
“name”: “FireTVDemo”,
“slug”: “FireTVDemo”
}
}
Running your project on a Fire TV device
To connect your Fire TV, follow the instructions here then check that your device is connected using adb:
Navigate to the project directory then run a development build on your target device (e.g. -d AFTSS)
npx expo run:android -d [deviceName]
You now have the development build installed on your device:
💡 You can verify your android builds are optimized for TV by checking that your app is using the Android leanback features in the Android manifest file.
Next steps
Congratulations on building your first React Native app for Amazon Fire Devices! To continue your learning journey you can:
Sign up for an Amazon Developer account
Join the Amazon Developer community
Integrate Amazon APIs in your app