Skip to content

Production safety

Hakka is a development tool. None of its capture, storage, or UI code should run — or even link — in a production build. Each platform has a different mechanism for guaranteeing this.

Gate start() behind the runtime dev flag for your environment. Hakka is a no-op until start() is called, so a skipped call is a skipped capture — no interceptors installed, no memory allocated.

React Native

instrumentation.ts
import { Hakka } from 'hakka-react-native'
if (__DEV__) {
Hakka.start({ mode: 'auto' })
}

__DEV__ is true in debug builds and false in release builds. Metro strips the unreachable branch from the production bundle.

Vite / web

src/hakka.ts
import { start } from 'hakka-browser'
if (import.meta.env.DEV) {
start()
}

import.meta.env.DEV is replaced at build time. The if body is tree-shaken out of production bundles.

Guard Capture runs? Code linked in release? Binary size impact
__DEV__ / import.meta.env.DEV No Yes (tree-shaken) Negligible after bundling
Next.js NODE_ENV guard No Yes (dead branch) Zero — register() returns immediately
Android debugImplementation No No — noop artifact only Zero
iOS HakkaNetworkNoop No No — noop product only Zero