Skip to content

Capture Modes

Hakka exposes four React Native capture modes: auto, native, js, and disabled.

Hakka.start({ mode: 'auto' })

auto prefers native capture when the native module is present and falls back to JS interception when it is not.

Use this as the default for most apps.

Hakka.start({ mode: 'native' })

native fails fast when the native module is missing. Use it in development builds or native-first apps where missing native capture should be treated as a configuration problem.

Native capture observes traffic made through native platform networking APIs.

Hakka.start({ mode: 'js' })

js intercepts fetch, XHR, and WebSocket traffic at the JavaScript layer. Use it when you intentionally want JS interception or when testing fallback behavior.

JS mode cannot observe traffic made directly by native SDKs.

Hakka.start({ mode: 'disabled' })

disabled installs nothing and captures nothing. Use it to keep a single call site while gating capture behind your own runtime flag.

WebSocket frame capture requires JS-layer interception. The JS package monkey-patches the global WebSocket API and captures individual message events (messages: WsMessage[] on NetworkRequest). The native OkHttp and URLProtocol interceptors only see the HTTP Upgrade handshake — not frames after the protocol switch.

Mode WebSocket frames captured?
js Yes
auto Yes — auto uses JS-layer capture for WebSocket traffic even when native mode is active for HTTP
native No — upgrade handshake only

The native layer can additionally capture WebSocket metadata (message count and close code, not frame payloads) opt-in: iOS via captureNativeWebSocket: true on a URLSessionWebSocketTask monitor, and Android via the OkHttp WebSocket listener wrapper. Frame payloads still require JS-layer capture.

JS mock rules are mirrored into native capture where supported, so mock behavior continues to work when auto selects the native path.