Do you know you can run React.js on your android device? Yes, you heard me right, you can actually run React.js using your android device.
In this article, I will be teaching You how you can run React.js on your android device using termux.
For you to be reading this article, I believe that you already have a good knowledge of JavaScript and React.js
Let's get started.
First thing you need to do is to install Termux on Google play store
What is Termux
Termux is an Android terminal emulator and Linux environment app that allows you to run a full fledged Linux distribution on your Android device without requiring root access.
Key Features:
Terminal Emulator: Provides a powerful command-line interface.
Package Management: Uses the pkg and apt package managers to install and manage Linux packages.
Linux Tools: Supports tools like git, python, nodejs, ssh, vim, and more.
Programming Environment: You can code in languages like Python, C, JavaScript, etc., directly on your phone.
Remote Access: You can SSH into remote servers or use your phone as a server itself.
Click here to install Termux or go to Google play store and search for Termux
Once you have installed Termux, first thing is to run Pkg update
, This will update all the packages you need to run React.js effortlessly.
Once that is done, you need to run Pkg upgrade
, this will upgrade all your packages that are out of date.
Let's set Termux storage
Now it's time to setup Termux storage. Because of Android policy, you cannot install React.js on your android phone storage, this is why we need to setup Termux storage, Termux storage is where all your files and projects will be stored, this is exactly where our React.js project will be stored, All you need is to run Termux-setup-storage
Let's install node
After our Termux storage have been set up, it is now time to install node.js, I believe that for you to be reading this article, you already know what node.js is all about. To install node, all you need is to run install nodejs
.
Note that node.js will be installed on your Termux storage and not your phone storage
To confirm that node was installed successfully, run node -v
and it will show you the node version that was installed
Now let's install React
I know this is the part you have been waiting for, now is time to install React. I love using vite.
Vite is a fast and modern build tool for front-end web development. It was created by Evan You, the creator of Vue.js, but it works with many frameworks like React, Vue, Svelte, and Vanilla JavaScript.
To install React with vite, we will run npm install vite@latest
, this will ask us enter or project name and the framework we want to install, we will select React.
After that it will ask us to move into our project folder and run npm install, to move into our project folder we will run cd folderName
, then I will also run npm install
, after everything is installed, i will run npm run dev
, Npm run dev will run a development server
Our development server will be running on port 5173, if we visit http://localhost:5173
we will see our React app running.
Congratulations, we have successfully installed React.js on our android device.
To start working on your React app, I will advice you to use Acode code editor. In my experience, Acode is the best android code editor that works with React, just go to playstore and search for Acode and get it installed, open your React folder on the Acode editor and you're good to go. If you will like me to write a detailed article about a using Acode and React please comment below.
Thanks for reading, follow me for more articles like this
Top comments (0)