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

@natsuneko-laboratory/react-native-twitter-text

v0.1.0

Published

A React Native plugin that provides Twitter's twitter-text parsing library via native Objective-C and Java implementations. Especially fast for CJK text compared to the JavaScript implementation.

Downloads

46

Readme

@natsuneko-laboratory/react-native-twitter-text

A React Native plugin that provides Twitter's twitter-text parsing library via native Objective-C and Java implementations. Especially fast for CJK text compared to the JavaScript implementation.

Features

  • Tweet parsing with weighted character count (v3 configuration)
  • Entity extraction (URLs, hashtags, @mentions, cashtags, lists)
  • Tweet validation
  • Synchronous API via React Native Turbo Modules (New Architecture)

Installation

npm install @natsuneko-laboratory/react-native-twitter-text
cd ios && pod install

Expo

npx expo install @natsuneko-laboratory/react-native-twitter-text

Add the plugin to your app.json:

{
  "expo": {
    "plugins": ["@natsuneko-laboratory/react-native-twitter-text"]
  }
}

Then run prebuild:

npx expo prebuild

Usage

Parse a tweet

import { parseTweet } from '@natsuneko-laboratory/react-native-twitter-text';

const result = parseTweet('Hello, world!');
// {
//   weightedLength: 13,
//   permillage: 46,
//   isValid: true,
//   displayTextRange: { start: 0, end: 13 },
//   validTextRange: { start: 0, end: 13 },
// }

Extract entities

import { extractEntities } from '@natsuneko-laboratory/react-native-twitter-text';

const entities = extractEntities(
  '@jack Check out #ReactNative https://reactnative.dev'
);
// [
//   { type: 'mention', value: '@jack', range: { start: 0, end: 5 } },
//   { type: 'hashtag', value: '#ReactNative', range: { start: 16, end: 28 } },
//   { type: 'url', value: 'https://reactnative.dev', range: { start: 29, end: 52 } },
// ]

Extract specific entity types

import {
  extractURLs,
  extractHashtags,
  extractMentions,
  extractMentionsOrLists,
  extractCashtags,
  extractReplyScreenname,
} from '@natsuneko-laboratory/react-native-twitter-text';

extractURLs('Visit https://example.com');
extractHashtags('Hello #world');
extractMentions('Hi @user!');
extractMentionsOrLists('@user/my-list'); // includes listSlug
extractCashtags('Buy $AAPL');
extractReplyScreenname('@user hello'); // '@user' or null

Validate tweets

import {
  isValidTweet,
  isValidHashtag,
  tweetLength,
} from '@natsuneko-laboratory/react-native-twitter-text';

isValidTweet('Hello!'); // true
isValidTweet(''); // false
isValidHashtag('#ReactNative'); // true
tweetLength('Hello!'); // 6

API Reference

Types

type EntityType = 'url' | 'hashtag' | 'mention' | 'listname' | 'cashtag';

interface TextRange {
  start: number;
  end: number;
}

interface Entity {
  type: EntityType;
  value: string;
  range: TextRange;
  listSlug?: string; // present for 'listname' entities
}

interface ParseResults {
  weightedLength: number;
  permillage: number;
  isValid: boolean;
  displayTextRange: TextRange;
  validTextRange: TextRange;
}

Functions

| Function | Return Type | Description | | ------------------------------ | ---------------- | ------------------------------------------------------------------- | | parseTweet(text) | ParseResults | Parse a tweet and return weighted length, validity, and text ranges | | extractEntities(text) | Entity[] | Extract all entities (URLs, hashtags, mentions, cashtags) | | extractURLs(text) | Entity[] | Extract URLs | | extractHashtags(text) | Entity[] | Extract hashtags | | extractMentions(text) | Entity[] | Extract @mentions | | extractMentionsOrLists(text) | Entity[] | Extract @mentions and list references | | extractCashtags(text) | Entity[] | Extract cashtags ($SYMBOL) | | extractReplyScreenname(text) | string \| null | Extract the replied-to screen name | | isValidTweet(text) | boolean | Check if a tweet is valid | | isValidHashtag(text) | boolean | Check if text is a valid hashtag | | tweetLength(text) | number | Get the weighted length of a tweet |

Requirements

  • React Native >= 0.76 (New Architecture / Turbo Modules)
  • iOS >= 13.4
  • Android minSdk >= 24

Contributing

Disclaimer

This project is not affiliated with, endorsed by, or sponsored by Twitter, Inc. (now X Corp.) or any of its subsidiaries. "twitter-text" refers to the open-source library published under the Apache 2.0 license.

License

  • MIT and Apache-2.0 and BSD-2-Clause (see LICENSE file for details)