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 🙏

© 2025 – Pkg Stats / Ryan Hefner

react-native-wireguard-vpn-connect

v1.0.15

Published

React Native WireGuard VPN package for iOS and Android

Readme

react-native-wireguard-vpn

A React Native module for implementing WireGuard VPN functionality in iOS and Android applications. This package provides a native implementation of WireGuard tunneling with a simple JavaScript interface.

Requirements

  • React Native >= 0.72.0
  • iOS 12.0 or later
  • Android API level 21 (Android 5.0) or later
  • CocoaPods for iOS development

Installation

# Using npm
npm install react-native-wireguard-vpn --save

# Using yarn
yarn add react-native-wireguard-vpn

iOS Setup

  1. Install CocoaPods dependencies:
cd ios && pod install && cd ..
  1. Add the following entries to your Info.plist:
<key>NSLocalNetworkUsageDescription</key>
<string>This app requires access to network features for VPN functionality</string>
<key>UIBackgroundModes</key>
<array>
    <string>network-authentication</string>
    <string>network</string>
</array>
  1. Add Network Extension capability to your iOS project:
    • Open your project in Xcode
    • Select your target
    • Go to "Signing & Capabilities"
    • Click "+" and add "Network Extensions"
    • Enable "Packet Tunnel" under Network Extensions

Android Setup

  1. Add the following permissions to your AndroidManifest.xml:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.BIND_VPN_SERVICE" />
  1. Update your app's build.gradle to ensure compatibility:
android {
    compileSdkVersion 34
    
    defaultConfig {
        minSdkVersion 21
        targetSdkVersion 34
    }
}

Usage

import WireGuardVpnModule, { 
  WireGuardConfig, 
  WireGuardStatus 
} from 'react-native-wireguard-vpn';

// Configuration object
const config: WireGuardConfig = {
  privateKey: 'YOUR_PRIVATE_KEY',
  publicKey: 'SERVER_PUBLIC_KEY',
  serverAddress: 'SERVER_IP',
  serverPort: 51820,
  allowedIPs: ['0.0.0.0/0'],
  dns: ['1.1.1.1'],
  mtu: 1450,
  presharedKey: 'OPTIONAL_PRESHARED_KEY' // Optional
};

// Initialize VPN service
await WireGuardVpnModule.initialize();

// Connect to VPN
try {
  await WireGuardVpnModule.connect(config);
  console.log('Connected successfully');
} catch (error) {
  console.error('Connection failed:', error);
}

// Check VPN status
const status: WireGuardStatus = await WireGuardVpnModule.getStatus();
console.log('VPN Status:', status);

// Disconnect from VPN
await WireGuardVpnModule.disconnect();

API Reference

Methods

initialize(): Promise<void>

Initializes the VPN service. Must be called before any other operations.

connect(config: WireGuardConfig): Promise<void>

Connects to the VPN using the provided configuration.

disconnect(): Promise<void>

Disconnects from the VPN.

getStatus(): Promise<WireGuardStatus>

Gets the current VPN connection status.

isSupported(): Promise<boolean>

Checks if WireGuard VPN is supported on the device.

Types

interface WireGuardConfig {
  privateKey: string;
  publicKey: string;
  serverAddress: string;
  serverPort: number;
  allowedIPs: string[];
  dns?: string[];
  mtu?: number;
  presharedKey?: string;
}

interface WireGuardStatus {
  isConnected: boolean;
  tunnelState: 'ACTIVE' | 'INACTIVE' | 'ERROR';
  error?: string;
}

Troubleshooting

Android

  • Ensure your app has the necessary permissions granted
  • Check logcat for detailed error messages
  • Make sure the VPN service is properly declared in AndroidManifest.xml

iOS

  • Verify Network Extension capability is properly configured
  • Check Xcode logs for detailed error messages
  • Ensure proper signing and provisioning profiles are set up

Example App

Check out the example app in our GitHub repository for a complete implementation.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT

Support

For bugs and feature requests, please create an issue on our GitHub repository.