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-s-pen

v0.1.2

Published

React Native library for Samsung S Pen support on Android

Readme

react-native-s-pen

React Native 0.86+ library for Samsung S Pen input, built with TurboModules and a Fabric-compatible native canvas.

Keywords: React Native, Android, Samsung S Pen, stylus, Air Actions, Air Motion, pressure-sensitive drawing, TurboModule, Fabric

Features

  • Stylus down, move, up, and hover events
  • Contact pressure, hover distance, and tilt
  • Pressure-sensitive native SpenCanvas
  • Samsung Remote button events
  • Samsung Air Motion X/Y deltas
  • S Pen Framework connection state
  • Best-effort physical insertion/removal state on compatible Samsung phones
  • Typed TypeScript API
  • Android New Architecture support

Requirements

  • React Native 0.86.0 or newer
  • React 19.2.3 or newer
  • Android API 24+
  • A Samsung device for Samsung-specific Remote features
  • S Pen Remote SDK 1.0.x for button and Air Motion support

Generic stylus events and SpenCanvas use Android MotionEvent. Remote button and Air Motion events require Samsung's SDK.

Installation

npm install react-native-s-pen

The Samsung SDK is not available from Maven and its downloaded binaries cannot be redistributed by this repository. Sign in to Samsung Developer, download the S Pen Remote SDK, and place these files in your application:

android/app/src/main/libs/sdk-v1.0.0.jar
android/app/src/main/libs/spenremote-v1.0.1.jar

Add the local SDK directory to android/app/build.gradle:

dependencies {
  implementation fileTree(dir: "src/main/libs", include: ["*.jar", "*.aar"])
}

Rebuild the Android application after adding the JARs.

Basic usage

import { SPen } from "react-native-s-pen";

const supported = await SPen.isSupported();
const deviceInfo = await SPen.getDeviceInfo();
const insertionState = await SPen.getPenInsertionState();
const connected = await SPen.isConnected();

const removeEvents = SPen.addListener((event) => {
  console.log(event.name, event.point, event.action);
});

const removeConnection = SPen.addConnectionStateListener((state) => {
  console.log("S Pen Framework:", state);
});

const removeInsertion = SPen.addPenInsertionStateListener((state) => {
  console.log("Physical pen:", state);
});

// Call each returned function when the consuming component unmounts.

Native canvas

SpenCanvas owns Android touch dispatch, so it works inside React Navigation and scroll views.

import { useState } from "react";
import { Button, View } from "react-native";
import { SpenCanvas } from "react-native-s-pen";

export function SignatureScreen() {
  const [clearToken, setClearToken] = useState(0);

  return (
    <View>
      <SpenCanvas
        style={{ height: 400 }}
        inkColor="#11140f"
        minStrokeWidth={2}
        maxStrokeWidth={18}
        clearToken={clearToken}
        onDraw={(point) => {
          console.log(point.x, point.y, point.pressure, point.tilt);
        }}
      />
      <Button title="Clear" onPress={() => setClearToken((value) => value + 1)} />
    </View>
  );
}

onDraw returns x, y, pressure, tilt, hoverDistance, timestamp, action, and toolType.

Events

| Event | Meaning | | --- | --- | | spen-down | Stylus touches the display | | spen-move | Stylus moves while touching | | spen-up | Stylus leaves the display | | spen-hover | Stylus moves above the display | | spen-button | Remote button down or up | | spen-air-action | Air Motion X/Y delta | | spen-insertion-state | Physical pen inserted, detached, or unknown | | spen-connection-state | Samsung S Pen Framework state | | spen-error | Samsung SDK error |

Pressure is normally zero while hovering. Use hoverDistance above the display and pressure while touching it.

Testing Remote features

  1. Enable Settings > Advanced features > S Pen > Air actions.
  2. Charge and remove the S Pen.
  3. Keep the application in the foreground.
  4. Press and release the side button to receive spen-button events.
  5. Move the detached pen to receive Air Motion deltas. On some devices, hold the button while moving.

isConnected() means the app is connected to Samsung's S Pen Framework. It does not mean that the physical pen is inserted or currently hovering.

Example app

The example directory contains separate screens for:

  • Framework and SDK diagnostics
  • Physical insertion/removal
  • Hover and tilt
  • Pressure-sensitive drawing
  • Remote button
  • Air Motion
  • Raw event inspection

After placing your downloaded SDK JARs in example/android/app/src/main/libs:

cd example
npm install
npm start
npm run android

Compatibility notes

  • Android only. Non-Android methods return safe fallback values where documented.
  • Insertion detection uses Samsung's sticky com.samsung.pen.INSERT broadcast. It is not part of the public Remote SDK contract, so unsupported devices return unknown.
  • Feature availability differs by Samsung model and S Pen generation.

Development

npm install
npm run typecheck

cd example/android
./gradlew :app:assembleDebug

Samsung SDK notice

Samsung SDK binaries are proprietary and are not included in this repository. Samsung and S Pen are trademarks of Samsung Electronics. This project is not affiliated with or endorsed by Samsung.