npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-native-tv-navigation

v0.1.2

Published

React Native TV TouchableOpacity wrapper with native forced directional focus.

Downloads

410

Readme

react-native-tv-navigation

react-native-tv-navigation exports TVTouchable, a small TouchableOpacity wrapper for React Native TV apps. It also exports requestTVFocus, a helper for imperatively moving focus to any mounted target ref.

TVTouchable keeps the standard TouchableOpacity behavior and adds directional forced focus props:

  • forceFocusUp
  • forceFocusDown
  • forceFocusLeft
  • forceFocusRight

Each prop accepts a React ref to the target element. When the current TVTouchable is focused and the user presses that direction on the TV remote, the component resolves the target with findNodeHandle and calls the native TVForceFocus.requestFocus(targetTag) method.

Installation

npm install react-native-tv-navigation

For iOS/tvOS, install pods:

cd ios
bundle exec pod install

This package is a normal native React Native library and supports React Native autolinking. The Android package is declared explicitly in react-native.config.js so the app can autolink the Kotlin native module reliably. It does not use Expo-only APIs.

Usage

import React, { useRef } from 'react';
import { Text, View } from 'react-native';
import { TVTouchable, requestTVFocus } from 'react-native-tv-navigation';

export function Example() {
  const buttonARef = useRef(null);
  const buttonBRef = useRef(null);

  return (
    <View>
      <TVTouchable
        ref={buttonARef}
        forceFocusUp={buttonBRef}
        onPress={() => {
          console.log('Button A pressed');
          requestTVFocus(buttonBRef);
        }}
      >
        <Text>Button A</Text>
      </TVTouchable>

      <TVTouchable ref={buttonBRef} forceFocusDown={buttonARef}>
        <Text>Button B</Text>
      </TVTouchable>
    </View>
  );
}

API

type TVTouchableProps = TouchableOpacityProps & {
  forceFocusUp?: React.RefObject<any> | null;
  forceFocusDown?: React.RefObject<any> | null;
  forceFocusLeft?: React.RefObject<any> | null;
  forceFocusRight?: React.RefObject<any> | null;
};

TVTouchable forwards its ref to the underlying TouchableOpacity and accepts all standard TouchableOpacity props. External onFocus, onBlur, onPress, and other handlers keep working normally.

function requestTVFocus(target: React.RefObject<any> | any | null | undefined): boolean;

requestTVFocus lets you move focus from any action, not only directional remote input. It accepts a ref or a mounted native target, resolves it with findNodeHandle, and calls the same native TVForceFocus.requestFocus(targetTag) method used by TVTouchable.

It returns true when a native focus request was sent and false when the target was empty, unmounted, or could not be resolved.

import React, { useRef } from 'react';
import { Text, View } from 'react-native';
import { TVTouchable, requestTVFocus } from 'react-native-tv-navigation';

export function ManualFocusExample() {
  const submitRef = useRef(null);
  const cancelRef = useRef(null);

  async function handleSubmit() {
    await saveChanges();
    requestTVFocus(cancelRef);
  }

  return (
    <View>
      <TVTouchable ref={submitRef} onPress={handleSubmit}>
        <Text>Save</Text>
      </TVTouchable>

      <TVTouchable ref={cancelRef}>
        <Text>Cancel</Text>
      </TVTouchable>
    </View>
  );
}

## Limitations

- The target ref must point to a mounted native element.
- The target element must be visible and focusable in the current TV layout.
- If the ref is empty, unmounted, or `findNodeHandle` returns `null`, the focus request safely does nothing.
- tvOS focus is still mediated by the UIKit focus engine, so platform rules can reject focus if the target is not currently eligible.