Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-native-vpn-detector

Package Overview
Dependencies
Maintainers
0
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-vpn-detector

React Native module to detect VPN connection

  • 0.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
8
increased by300%
Maintainers
0
Weekly downloads
 
Created
Source

🌐 react-native-vpn-detector

React Native module to detect VPN connection

📦 Installation

To install the module, you can use npm:

## You must install @react-native-community/netinfo first
npx expo install @react-native-community/netinfo
npm install react-native-vpn-detector

⚠️ Note

The VPN detector does not work on simulators. Please test on a real device.

🚀 Usage

🧩 useIsVpnActive

The useIsVpnActive hook provides a way to use the VPN connection status within a React component.

import React from "react";
import { View, Text } from "react-native";
import { useIsVpnActive } from "react-native-vpn-detector";

const App = () => {
  const isVpnActive = useIsVpnActive();

  return (
    <View>
      <Text>VPN is {isVpnActive ? "active" : "inactive"}</Text>
    </View>
  );
};

🔍 isVpnActive

The isVpnActive function checks if a VPN connection is active.

import React from "react";
import { View, Text } from "react-native";
import { isVpnActive } from "react-native-vpn-detector";

const value = isVpnActive();
const App = () => {
  return (
    <View>
      <Text>VPN is {value ? "active" : "inactive"}</Text>
    </View>
  );
};

📡 addEventListener

The addEventListener function listens for changes in the VPN connection status.

import React, { useEffect } from "react";
import { View, Text } from "react-native";
import { addEventListener } from "react-native-vpn-detector";

const App = () => {
  useEffect(() => {
    const listener = (isVpnActive) => {
      console.log(`VPN is now ${isVpnActive ? "active" : "inactive"}`);
    };

    const unsubscribe = addEventListener(listener);

    return () => {
      unsubscribe();
    };
  }, []);

  return (
    <View>
      <Text>Listening for VPN status changes...</Text>
    </View>
  );
};

🤝 Contributing

Contributions are welcome! Please open an issue or submit a pull request for any bugs or enhancements.

📜 License

This project is licensed under the MIT License. See the LICENSE file for more information.

Keywords

FAQs

Package last updated on 26 Jul 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc