# @rootnative/impulse > Declarative gesture primitives for React Native, built on > react-native-gesture-handler. One hook per intent. Hooks return shared values > and a gesture. Impulse starts no animation and ships no components. Status: 0.0.0-alpha.3. Eight intents ship. A device sweep on an Android emulator and an iOS simulator drove every intent. It proves mechanics, not feel, so every default below is still a design intention. Docs: https://rootnative.github.io/impulse/ Full: https://rootnative.github.io/impulse/llms-full.txt Source: https://github.com/rootnative/impulse ## Install Platforms: iOS and Android supported (alpha; every intent driven on a simulator and an emulator, no physical device). Web partial: useTap, useDoubleTap, useLongPress, useDrag checked under a mouse in a desktop browser; usePan, useSwipe, usePinch, useRotate not checked; no automated web test. Web needs react-dom and react-native-web. Electron, macOS, Windows: not tested. Details: https://rootnative.github.io/impulse/installation#platforms and https://rootnative.github.io/impulse/web npm install @rootnative/impulse Peers (the Expo SDK 58 band): react >=19.3.0, react-native >=0.88.0 <0.89.0, react-native-gesture-handler >=3.3.0 <4.0.0, react-native-reanimated >=4.7.0 <4.8.0, react-native-worklets >=0.13.0 <0.14.0. An Expo SDK 57 app uses 0.0.0-alpha.1. Impulse builds gestures with the RNGH builder API (Gesture.Pan()); an RNGH 3 hook gesture (usePanGesture) does not compose with an Impulse gesture. Render a above every component that uses a gesture. If it is missing, gestures never fire. RNGH 3 throws in development on iOS and Android, and in Jest (wrap each render: { wrapper: GestureHandlerRootView }). On web and in a release build, nothing warns. ## What ships Intent hooks: useTap, useDoubleTap, useLongPress, useDrag, usePan, useSwipe, usePinch, useRotate. Composition: useGestures. Escape hatch: useRawGesture. The package entry re-exports GestureDetector. NOT IMPLEMENTED, do not import: useHover, useEdgeSwipe. They are designed only. usePan and useDrag are not synonyms. useDrag owns a position: x and y accumulate across gestures and bounds clamps them. usePan owns nothing: it reports translation, velocity, and a per-frame change that you add up, and it zeroes at every gesture. useSwipe is a pan judged at release. directions is also the activation criterion. An all-horizontal list gives a directional threshold, so the swipe shares a view with a vertical scroller with no relation declared. usePinch owns a scale that accumulates across gestures, so min and max are the viewer's zoom range, not one gesture's. focal is the midpoint between the fingers, and the point the zoom must happen about. A zoom about the centre of the view slides the content out from under the fingers. It has NO activation criteria. RNGH's pinch exposes no threshold, so only a relation separates a pinch and a pan: useGestures([pinch, pan], { mode: 'simultaneous' }). useRotate reports DEGREES, not the radians RNGH reports. This is the one place Impulse changes a unit: min: -45, not -Math.PI / 4. It applies to angle, gestureAngle, velocity and the min/max range. The angle accumulates and does NOT wrap. A second full turn reports 720. anchor is the point the turn happens about, the counterpart of pinch's focal. It has NO activation criteria either, so you compose rotate and pinch as simultaneous. Subpaths: @rootnative/impulse/{tap,double-tap,long-press,drag,pan,swipe,pinch,rotate,compose,raw,gesture-handler} ## The shape of every hook const tap = useTap({ onTap: select }) tap.gesture // hand to tap.ref // name it in another hook's alongside / blocks / deferTo tap.isActive // SharedValue useDrag adds x and y, both SharedValue, both writable, both accumulating across gestures. ## Threads — the callback name states the thread JS thread: onTap, onDoubleTap, onLongPress, onLongPressEnd, onDragStart, onDragEnd, onPanStart, onPanEnd, onSwipe, onSwipeEnd, onPinchStart, onPinchEnd, onRotateStart, onRotateEnd. They are ordinary functions. Impulse owns the scheduleOnRN boundary. Every callback that reports an ending takes a second argument, { cancelled }: onTap, onDoubleTap, onLongPressEnd, onDragEnd, onPanEnd, onSwipeEnd, onPinchEnd, onRotateEnd. It fires on both endings. cancelled is true when the system took the gesture away: a competing gesture won, the app went to the background, or a relation handed the touch on. onSwipe fires for a commit only and takes no second argument. Worklets: onBegin, onUpdate, onFinalize. Mark them with 'worklet'. A plain function there makes Impulse warn once in development, and the warning names the hook and the callback. Without the directive, the first touch that reaches the phase throws "Tried to synchronously call a Remote Function". Worklets are direct gesture dependencies, so keep their identity stable. An inline worklet rebuilds the gesture on every render. An inline JS-thread callback doesn't. ## Composition useGestures(members, { mode }) where mode is race | simultaneous | exclusive. A composed result is itself a member. Precedence reads left to right. A tap and a double tap are exclusive with the double tap FIRST, never race. A single tap recognizes on the first release and would win every race. The composed single tap then pays maxDelay in latency. useGestures doesn't accept coexistence options. Put them on the members. ## Coexistence alongside -> both recognize (simultaneousWithExternalGesture) blocks -> this gesture wins (blocksExternalGesture) deferTo -> the named gesture wins (requireExternalGestureToFail) Name another hook's .ref, not its .gesture. TRAP: a relation target must carry a handlerTag. React Native's ScrollView has none, and neither has RNGH 3's own ScrollView, so RNGH drops the relation SILENTLY on every platform. Use LegacyScrollView / LegacyFlatList, from @rootnative/impulse/gesture-handler. TRAP: a component ref needs `as unknown as GestureReference`. RNGH types the target as a ref to a component type, and ref={} doesn't produce that type. ## Defaults useTap: pointers 1, maxDuration 500ms, maxDistance 10pt useDoubleTap: same, plus maxDelay 500ms (probably too generous; 250-300 is closer to what platforms use) useLongPress: minDuration 500ms, maxDistance 10pt useDrag: axis both, threshold 10pt, elastic 0, unbounded usePan: axis both, threshold 10pt useSwipe: directions all four, threshold 10pt, commitDistance 80pt, commitSpeed 800pt/s usePinch: initial 1, unbounded, no activation criteria useRotate: initial 0, unbounded, no activation criteria No default has a feel result. The device sweep proved that the drag threshold, commitDistance, and maxDelay at 500ms and 250ms work. commitSpeed is not tested, because neither harness can make a swipe that fast. ## isActive does not mean the same thing in every hook useTap and useDoubleTap set it at touch-down. For useTap that is a real pressed state. For useDoubleTap it is true for every ordinary single tap on the view too, so don't drive a pressed state from it. useLongPress, useDrag, usePan, useSwipe, usePinch and useRotate set it at recognition. ## Known gaps a consumer can hit - Impulse reports a cancel, but its velocity is not a throw. The finger never lifted on a cancelled gesture, so a spring on velocity when cancelled is true flings a view that the finger never released. - useLongPress maxDistance cancels an ACTIVE press on web, against RNGH's own documented contract. Hold-then-drag doesn't work there at the default. - A missing fails silently on web and in a release build. Impulse adds no warning of its own. - Web is surveyed by hand. No jsdom test pins any of it. ## Out of scope, by decision No components. No animation vocabulary, springs or easing. No haptics policy. useDrag returns values and no style. @rootnative/inertia-gestures has a useDrag that returns an animatedStyle and requires @rootnative/inertia.