{"id":49089,"library":"react-native-websocket-self-signed","title":"react-native-websocket-self-signed","description":"A React Native package (v0.5.0, released under MIT) that enables WebSocket (wss://) connections with self-signed SSL/TLS certificates by bypassing certificate validation. It uses a singleton pattern to manage connections and supports multiple concurrent WebSocket instances. Alternative to manually patching native modules for development or internal apps where strict certificate verification is not required. Includes TypeScript declarations. WARNING: Bypassing SSL validation exposes to MITM attacks and must never be used in production.","status":"active","version":"0.5.0","language":"javascript","source_language":"en","source_url":"https://github.com/yuyak97/react-native-websocket-self-signed","tags":["javascript","react-native","ios","android","typescript"],"install":[{"cmd":"npm install react-native-websocket-self-signed","lang":"bash","label":"npm"},{"cmd":"yarn add react-native-websocket-self-signed","lang":"bash","label":"yarn"},{"cmd":"pnpm add react-native-websocket-self-signed","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency required for React Native integration","package":"react","optional":false},{"reason":"peer dependency required for React Native native modules","package":"react-native","optional":false}],"imports":[{"note":"ESM default import; CommonJS require may not work in some bundlers. TypeScript types are included.","wrong":"const WebSocketWithSelfSignedCert = require('react-native-websocket-self-signed')","symbol":"default","correct":"import WebSocketWithSelfSignedCert from 'react-native-websocket-self-signed'"},{"note":"The package exports a class as default; named import 'WebSocketWithSelfSignedCert' does not exist (use default import).","symbol":"WebSocketWithSelfSignedCert","correct":"import WebSocketWithSelfSignedCert from 'react-native-websocket-self-signed'"},{"note":"Static factory method to get or create a WebSocket instance per URL. Available since v0.4.0.","symbol":"getInstance","correct":"const ws = WebSocketWithSelfSignedCert.getInstance(url)"}],"quickstart":{"code":"import WebSocketWithSelfSignedCert from 'react-native-websocket-self-signed';\n\nconst url = 'wss://localhost:8443';\nconst ws = WebSocketWithSelfSignedCert.getInstance(url);\n\nws.onopen = () => {\n  console.log('Connected to', url);\n  ws.send('Hello, server!');\n};\n\nws.onmessage = (event) => {\n  console.log('Received:', event.data);\n};\n\nws.onerror = (error) => {\n  console.error('WebSocket error:', error.message);\n};\n\nws.onclose = (event) => {\n  console.log('Connection closed:', event.code, event.reason);\n};","lang":"typescript","description":"Shows how to import, create a WebSocket instance for a URL (singleton per URL), and handle events."},"warnings":[{"fix":"Update to use WebSocketWithSelfSignedCert.getInstance(url) for each WebSocket URL.","message":"In v0.4.0, the API changed from a single connection to multiple connections using getInstance(url). Code using the old global singleton will break.","severity":"breaking","affected_versions":"<0.4.0"},{"fix":"Do not use in production. Only for development or internal apps where risk is acceptable.","message":"This package bypasses SSL/TLS certificate validation, which is a security risk.","severity":"deprecated","affected_versions":"all"},{"fix":"Disable network inspector via expo-build-properties plugin in app.json (see README).","message":"On iOS, the expo-dev-client network inspector intercepts requests preventing this library from working in dev builds.","severity":"gotcha","affected_versions":"all"},{"fix":"Replace localhost with 10.0.2.2 for Android emulator connections.","message":"On Android emulator, use wss://10.0.2.2:port instead of localhost to connect to host machine.","severity":"gotcha","affected_versions":"all"},{"fix":"Ensure getInstance is called after React Native initialization (e.g., inside useEffect or after app startup).","message":"The getInstance method may cause race conditions if called before native module is ready (e.g., in component mount before React Native initialization).","severity":"gotcha","affected_versions":">=0.4.0"}],"env_vars":null,"search_vec":"'altern':43 'android':84 'app':53 'attack':71 'bypass':26,65 'certif':24,27,56 'concurr':40 'connect':18,36 'declar':63 'develop':50 'enabl':16 'expos':68 'includ':61 'instanc':42 'intern':52 'io':83 'javascript':79 'manag':35 'manual':45 'mit':14 'mitm':70 'modul':48 'multipl':39 'must':73 'nativ':3,9,47,82 'never':74 'packag':10 'patch':46 'pattern':33 'product':78 'react':2,8,81 'react-nat':80 'react-native-websocket-self-sign':1 'releas':12 'requir':60 'self':5,21 'self-sign':20 'sign':6,22 'singleton':32 'ssl':66 'ssl/tls':23 'strict':55 'support':38 'typescript':62,85 'use':30,76 'v0.5.0':11 'valid':28,67 'verif':57 'warn':64 'websocket':4,17,41","created_at":"2026-06-07T17:00:00.040556+00:00","updated_at":"2026-06-07T17:00:00.040556+00:00","problems":[{"fix":"Use this library to bypass validation, or install a proper certificate.","cause":"iOS default URLSession does not trust self-signed certificates.","error":"Error: WebSocket connection to 'wss://...' failed: Error Domain=NSURLErrorDomain Code=-1202 \"The certificate for this server is invalid. You might be connecting to a server that is pretending to be ... which could put your confidential information at risk.\""},{"fix":"Use import WebSocketWithSelfSignedCert from 'react-native-websocket-self-signed'","cause":"CommonJS require() used instead of default import; bundler may not resolve default export correctly.","error":"TypeError: Cannot read property 'getInstance' of undefined"},{"fix":"Replace 'localhost' with '10.0.2.2' in the WebSocket URL.","cause":"On Android emulator, using localhost instead of 10.0.2.2.","error":"Network request failed - The request timed out."},{"fix":"Update package to v0.4.0+ and use getInstance(url).","cause":"Trying to use getInstance on older version <0.4.0 where global singleton was used directly.","error":"TypeError: WebSocketWithSelfSignedCert.getInstance is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/yuyak97/react-native-websocket-self-signed#readme","github":"https://github.com/yuyak97/react-native-websocket-self-signed","docs":null,"changelog":null,"pypi":null,"npm":"react-native-websocket-self-signed","openapi_spec":null,"status_page":null,"smithery":null,"categories":["security","devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}