A native WireGuard VPN client for React Native (Expo) with iOS support.
Caution
This package is under development. PRs are welcome.
- WireGuard VPN tunneling for iOS
- Configuration management (add, remove, list)
- Connection state monitoring
- Key generation utilities
- Background VPN operation via Network Extension
- TypeScript support
npm install expo-wireguard- iOS 15.1+ with Network Extension capability
- Apple Developer account with Network Extension entitlement
- Basic WireGuard configuration knowledge
- Add the plugin to your
app.jsonwith your Apple Developer Team ID:
{
"expo": {
"plugins": [
[
"expo-wireguard",
{
"developmentTeam": "YOUR_TEAM_ID"
}
]
],
"ios": {
"bundleIdentifier": "com.yourcompany.yourapp"
}
}
}- Generate native files:
npx expo prebuildThat's it! The plugin automatically:
- Creates the Network Extension target
- Configures required entitlements
- Sets up proper code signing
- Links the WireGuard framework
import { useEvent } from 'expo';
import ExpoWireguard from 'expo-wireguard';
function VPNComponent() {
const connectionStateChange = useEvent(ExpoWireguard, 'onConnectionStateChange');
const connect = async () => {
const config = {
name: 'MyVPN',
privateKey: 'YOUR_PRIVATE_KEY',
address: '10.0.0.2/32',
dns: '1.1.1.1',
peers: [{
publicKey: 'PEER_PUBLIC_KEY',
endpoint: 'server.com:51820',
allowedIPs: '0.0.0.0/0'
}]
};
await ExpoWireguard.addConfiguration(config);
await ExpoWireguard.connect('MyVPN');
};
// ...
}generateKeyPair()- Generate WireGuard key pairaddConfiguration(config)- Add VPN configurationconnect(name)- Connect to VPNdisconnect()- Disconnect VPNgetConnectionState()- Get current statelistConfigurations()- List saved configs
onConnectionStateChange- Connection state updatesonError- Error notifications
interface WireGuardConfiguration {
name: string;
privateKey: string;
address: string;
dns?: string;
peers: Array<{
publicKey: string;
endpoint: string;
allowedIPs: string;
persistentKeepalive?: number;
}>;
}Contributions welcome! Submit PRs or issues.
MIT