npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

instagram-private-api-rn

v9.0.4

Published

React Native compatibility layer for instagram-private-api

Readme

Instagram Private API React Native Compatibility Layer

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.

Installation

# 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

Metro Configuration

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,
      },
    }),
  },
};

Usage

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);

Features

This compatibility layer provides polyfills for the following Node.js modules:

  • crypto: Implements cryptographic functions using React Native compatible libraries
  • http: Replaces request/request-promise with a fetch-based implementation
  • buffer: Provides a Buffer implementation for React Native
  • fs: Implements file system operations using @dr.pogodin/react-native-fs
  • cookies: Replaces tough-cookie with a React Native compatible cookie storage
  • util: Provides utility functions like promisify
  • net: Implements network utility functions used by tough-cookie
  • url: Provides URL parsing and formatting functions
  • events: Implements EventEmitter for event handling
  • tls: Provides TLS/SSL functionality for secure connections

Advanced Usage

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();
// ...

Dependencies

This package depends on the following libraries:

  • 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
  • stream-browserify
  • path-browserify
  • browserify-zlib
  • stream-http
  • https-browserify
  • querystring-es3
  • os-browserify
  • constants-browserify
  • vm-browserify
  • assert
  • tty-browserify
  • process

Make sure to install and properly link these dependencies in your React Native project.

Limitations

  • Some advanced cryptographic operations might not work exactly the same as in Node.js
  • File operations are limited to what @dr.pogodin/react-native-fs supports
  • Performance might differ from the Node.js version

License

This package is licensed under the MIT License.