
Security News
Deno 2.6 + Socket: Supply Chain Defense In Your CLI
Deno 2.6 introduces deno audit with a new --socket flag that plugs directly into Socket to bring supply chain security checks into the Deno CLI.
react-native-simple-openvpn
Advanced tools
English | 简体ä¸ć–‡
A simple react native module to interact with OpenVPN
| RNSimpleOpenvpn | React Native |
|---|---|
| 0.56 ~ 0.65 |
# npm
npm install --save react-native-simple-openvpn
# or use yarn
yarn add react-native-simple-openvpn
From react-native 0.60 autolinking will take care of the link step
react-native link react-native-simple-openvpn
If using CocoaPods, run it in the ios/ directory
pod install
See iOS Guide for iOS side Network Extension configuration and OpenVPN integration
import React, { useEffect } from 'react';
import { Platform } from 'react-native';
import RNSimpleOpenvpn, { addVpnStateListener, removeVpnStateListener } from 'react-native-simple-openvpn';
const isIPhone = Platform.OS === 'ios';
const App = () => {
useEffect(() => {
async function observeVpn() {
if (isIPhone) {
await RNSimpleOpenvpn.observeState();
}
addVpnStateListener((e) => {
// ...
});
}
observeVpn();
return async () => {
if (isIPhone) {
await RNSimpleOpenvpn.stopObserveState();
}
removeVpnStateListener();
};
});
async function startOvpn() {
try {
await RNSimpleOpenvpn.connect({
remoteAddress: '192.168.1.1 3000',
ovpnFileName: 'client',
assetsPath: 'ovpn/',
providerBundleIdentifier: 'com.example.RNSimpleOvpnTest.NEOpenVPN',
localizedDescription: 'RNSimpleOvpn',
});
} catch (error) {
// ...
}
}
async function stopOvpn() {
try {
await RNSimpleOpenvpn.disconnect();
} catch (error) {
// ...
}
}
function printVpnState() {
console.log(JSON.stringify(RNSimpleOpenvpn.VpnState, undefined, 2));
}
// ...
};
export default App;
| Name | iOS | Android | Parameters | Return | Description |
|---|---|---|---|---|---|
| connect | âś… | âś… | options: VpnOptions | promise | Connecting to OpenVPN |
| disconnect | âś… | âś… | none | promise | Close the OpenVPN connection |
| observeState | ✅ | ❌ | none | promise | Listening for VPN status |
| stopObserveState | ✅ | ❌ | none | promise | Stop listening to VPN status |
| addVpnStateListener | âś… | âś… | callback: (e: VpnEventParams) => void | void | Add VPN status change event listener |
| removeVpnStateListener | âś… | âś… | none | void | Remove the VPN status change event listener |
| Name | Value | Description |
|---|---|---|
| VpnState | VPN_STATE_DISCONNECTED = 0 VPN_STATE_CONNECTING = 1 VPN_STATE_CONNECTED = 2 VPN_STATE_DISCONNECTING = 3 VPN_OTHER_STATE = 4 | VPN Current Status |
interface VpnOptions {
remoteAddress?: string;
ovpnFileName?: string;
assetsPath?: string;
providerBundleIdentifier: string;
localizedDescription?: string;
}
VPN server address, the format is <ip> <port>, use the address in the configuration file of xxx.ovpn when it is not passed in
The name of the OpenVPN configuration file, without extensions, using the default name client if not passed in
Android only,the path to the OpenVPN configuration file under android/app/src/main/assets/
assetsPath is '' when not passed in, the file path is assets/xxx.ovpn'ovpn/', the file path is assets/ovpn/xxx.ovpniOS only,the bundle identifier of the Network Extension target
iOS only,the localized description name of the app in Settings -> VPN. If it is not passed in, the default name RNSimpleOpenvpn will be used
interface VpnEventParams {
state: RNSimpleOpenvpn.VpnState; // VPN Status
message: string; // VPN Status Related Messages
level?: string; // Description of the connection status provided by the Android OpenVPN library
}
xxx.ovpn configuration fileDon't forget to add the configuration file to your project
The Android path is android/app/src/main/assets/,create a new assets folder if you don't have one
The iOS path is the main bundle, just drag and drop the file into the project

The format of the line where remote is located in the file must be of the following form
...
remote <IP address> <port>
...
If you don't need to dynamically modify the remote address in the configuration file, the same configuration file is used for Android and iOS, and the remoteAddress of options can be left out
However, if you need to dynamically change the remote address in the configuration file, the iOS configuration file needs to comment out the line where remote is located (below) and always pass remoteAddress for options
...
;remote <IP address> <port>>
...
The following items were used in this project
react-native-simple-openvpn is available under the GPLv2 license. See the LICENSE file for more information
FAQs
React Native Open VPN Module
The npm package react-native-simple-openvpn receives a total of 72 weekly downloads. As such, react-native-simple-openvpn popularity was classified as not popular.
We found that react-native-simple-openvpn demonstrated a not healthy version release cadence and project activity because the last version was released 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.

Security News
Deno 2.6 introduces deno audit with a new --socket flag that plugs directly into Socket to bring supply chain security checks into the Deno CLI.

Security News
New DoS and source code exposure bugs in React Server Components and Next.js: what’s affected and how to update safely.

Security News
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.