In React Native, external libraries and tools are added to your project using npm or yarn. These packages extend functionality such as navigation, animations, networking, device APIs, and UI components.
React Native projects are JavaScript-based, so npm packages are installed using terminal commands. After installation, the library can be imported and used in your components.
// Install a package using npm
npm install axios
// Importing the installed package in a React Native file
import axios from "axios";
node_modulespackage.json is updated with the dependencyUse the simulator below to practice installing a package. Watch how the Terminal command updates the package.json file in real-time.
npm install axios or npm install moment and press Enter.
{
"name": "MyReactNativeApp",
"version": "1.0.0",
"dependencies": {
"react": "18.2.0",
"react-native": "0.72.0"
}
}
Think of npm packages as plug-and-play modules. Once installed, they behave like built-in tools that can be imported anywhere in your app.
// Visualizing dependency usage in code flow
App.js → import package → use features → render output
npm uninstall to remove unused packages