This guide will help you set up a React Native weather app using TailwindCSS. Follow the steps below to get your development environment ready.
First, you need to install Node.js and npm. Download the prebuilt installer from the Node.js website and follow the installation instructions.
Open your terminal and run the following command to create a new Expo app using the template:
npx create-expo-app --template
Change to your app directory with the following command:
cd yourAppName
To use Heroicons in your app, install react-native-heroicons and react-native-svg:
npm install react-native-heroicons react-native-svg
Next, install react-n ative-progress
to display progress indicators in your app:
npm install react-native-progress
Install axios
to make HTTP requests to fetch weather data:
npm install axios
a. Install NativeWind
npm install nativewind
b. Install TailwindCSS Install TailwindCSS as a development dependency:
npm install --save-dev [email protected]
c. Initialize TailwindCSS Run the following command to create a TailwindCSS configuration file:
npx tailwindcss init
d. Configure TailwindCSS
Replace the contents of tailwind.config.js
with the following configuration:
// tailwind.config.js
module.exports = {
content: ["./App.{js,jsx,ts,tsx}", "./screens/**/*.{js,jsx,ts,tsx}"],
theme: {
extend: {},
},
plugins: [],
}
e. Configure Babel
e. Configure Babel
Replace the contents of babel.config.js
with the following configuration:
// babel.config.js
module.exports = function (api) {
api.cache(true);
return {
presets: ["babel-preset-expo"],
plugins: ["nativewind/babel"],
};
};
Finally, start the Expo development server with the following command:
npx expo start
If you need to use the tunnel option, use:
npx expo start --tunnel