If you are already working with React Native, you can easily target Amazon Fire OS devices without learning a new tech stack or maintaining separate codebases. The Expo framework provides an easy and fast development experience — covered in this guide for how to get up and running with React Native for apps on both Fire TVs and tablets.
Before getting started, install the following:
Configure Android Studio and its command-line tools:
For tablet:
For TV:
In the terminal, create a new React Native project with the expo package installed:
npx create-expo-app FireTabletDemo --template blank
Running on Fire tablet emulator
List the available avds then launch the Android Tablet:
emulator -list-avds
emulator -avd name-of-your-tablet-emulator
Navigate to the project directory (e.g. FireTabletDemo
) and run the app using npx:
cd FireTabletDemo
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 these instructions for connecting to Fire tablet through Android Debug Bridge (ADB). Afterwards, confirm it is available as a device:
adb devices -l
Navigate to the project directory then run a development build on your target device (e.g. KFTRWI)
cd FireTabletDemo
npx expo run:android -d [deviceName]
The development build will now install within the Android directory:
Building for Fire TVs is a similar process as tablets. In a new directory, create a new React Native project with the expo, this time using the with-tv
example:
npx create-expo-app FireTVDemo -e with-tv
Running on Fire TV emulator
Launch the Android TV emulator:
emulator -avd name-of-your-tv-emulator
Navigate to the project directory and run your app:
cd FireTVDemo
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
Follow these instructions for connecting to Fire TV through Android Debug Bridge (ADB). Afterwards, confirm it is available as a device:
adb devices -l
Navigate to the project directory then run a development build on your target device (e.g. -d AFTSS)
cd FireTVDemo
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.
Congratulations on building your first React Native app for Fire OS! Check out these additional resources for building for Amazon devices with React Native: