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:
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 the instructions here to connect your tablet via 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
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:
npx create-expo-app FireTVDemo -e with-tv
Running on Android 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
To connect your Fire TV, follow the instructions here then check that your device is connected using adb:
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.
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
Top comments (2)
This is a really informative guide on using React Native for Fire OS devices! I was wondering, do you have any tips for optimizing performance on these devices?
Hey Ethan, great question, I recommend checking out this guide from callstack - callstack.com/ebook/the-ultimate-g.... We are hoping to contribute to a section focused on TV soon!