
Product
Socket for Jira Is Now Available
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.
instagram-private-api-rn
Advanced tools
This package provides a compatibility layer for using the instagram-private-api library in React Native applications. It includes polyfills and replacements for Node.js-specific modules that are not available in React Native.
# Install the main instagram-private-api library
npm install instagram-private-api
# Install this compatibility layer
npm install instagram-private-api-rn
# Install required dependencies
npm install buffer react-native-randombytes react-native-fast-crypto react-native-rsa-native @dr.pogodin/react-native-fs @react-native-async-storage/async-storage react-native-url-polyfill
# Install additional dependencies for Metro configuration
npm install stream-browserify path-browserify browserify-zlib stream-http https-browserify querystring-es3 os-browserify constants-browserify vm-browserify assert tty-browserify process
You need to configure Metro bundler to handle Node.js modules. Create or update your metro.config.js file:
module.exports = {
resolver: {
extraNodeModules: {
// Provide empty implementations or polyfills for Node.js modules
net: require.resolve('instagram-private-api-rn/polyfills/net'),
fs: require.resolve('instagram-private-api-rn/polyfills/fs'),
crypto: require.resolve('instagram-private-api-rn/polyfills/crypto'),
url: require.resolve('instagram-private-api-rn/polyfills/url'),
util: require.resolve('instagram-private-api-rn/polyfills/util'),
events: require.resolve('instagram-private-api-rn/polyfills/events'),
tls: require.resolve('instagram-private-api-rn/polyfills/tls'),
buffer: require.resolve('buffer'),
stream: require.resolve('stream-browserify'),
path: require.resolve('path-browserify'),
zlib: require.resolve('browserify-zlib'),
http: require.resolve('stream-http'),
https: require.resolve('https-browserify'),
querystring: require.resolve('querystring-es3'),
os: require.resolve('os-browserify/browser'),
constants: require.resolve('constants-browserify'),
vm: require.resolve('vm-browserify'),
assert: require.resolve('assert'),
tty: require.resolve('tty-browserify'),
'process/browser': require.resolve('process/browser'),
},
},
transformer: {
getTransformOptions: async () => ({
transform: {
experimentalImportSupport: false,
inlineRequires: true,
},
}),
},
};
import { IgApiClient } from 'instagram-private-api';
import { patchAll } from 'instagram-private-api-rn';
import AsyncStorage from '@react-native-async-storage/async-storage';
// Apply all polyfills to make instagram-private-api compatible with React Native
const ig = new IgApiClient();
patchAll({
IgApiClient,
storage: AsyncStorage, // Optional: for persistent cookie storage
});
// Now you can use the instagram-private-api library as usual
async function login() {
ig.state.generateDevice('username');
await ig.account.login('username', 'password');
// Do something with the logged in client
const userFeed = ig.feed.user('some-user-id');
const posts = await userFeed.items();
console.log(posts);
}
login().catch(console.error);
This compatibility layer provides polyfills for the following Node.js modules:
You can also use individual polyfills if you need more control:
import { IgApiClient } from 'instagram-private-api';
import { patchHttp, patchCrypto, patchBuffer, patchNet, patchUrl, patchEvents, patchTls } from 'instagram-private-api-rn';
// Apply only specific polyfills
patchBuffer();
patchCrypto();
patchNet();
patchUrl();
patchEvents();
patchTls();
patchHttp(IgApiClient);
// Now you can use the instagram-private-api library with these polyfills
const ig = new IgApiClient();
// ...
This package depends on the following libraries:
Make sure to install and properly link these dependencies in your React Native project.
This package is licensed under the MIT License.
FAQs
React Native compatibility layer for instagram-private-api
The npm package instagram-private-api-rn receives a total of 11 weekly downloads. As such, instagram-private-api-rn popularity was classified as not popular.
We found that instagram-private-api-rn demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.