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

kuromoji-react-native

v1.0.1

Published

React Native (Expo) compatible Japanese morphological analyzer, fork of kuromoji.js

Readme

kuromoji-react-native

npm version

React Native (Expo) compatible fork of kuromoji.js, a JavaScript implementation of a Japanese morphological analyzer.

This fork replaces the Node.js and browser-specific dictionary loading with a fetch()-based loader that works in React Native's Hermes engine. The core tokenizer is unchanged, as it was already pure JavaScript.

What changed from upstream

Only the dictionary loading layer was modified (3 files). The tokenizer core (~20 files) is untouched.

  • DictionaryLoader.js: removed require("path"), added resolvePath() supporting both URL strings and asset maps
  • ReactNativeDictionaryLoader.js: new loader using fetch() + zlibjs, works with both remote URLs and local file:// URIs
  • TokenizerBuilder.js: imports the React Native loader by default

Installation

Install from npm:

npx expo install kuromoji-react-native

The dictionary files (~17MB compressed) are included in the package under dict/.

Setup

1. Configure Metro to bundle .gz files

// metro.config.js
const { getDefaultConfig } = require('expo/metro-config');
const config = getDefaultConfig(__dirname);
config.resolver.assetExts.push('gz');
module.exports = config;

2. Register dictionary assets

Metro requires static require() calls, so each file must be listed explicitly:

import { Asset } from 'expo-asset';

const DICT_ASSETS = {
  'base.dat.gz': require('kuromoji-react-native/dict/base.dat.gz'),
  'check.dat.gz': require('kuromoji-react-native/dict/check.dat.gz'),
  'tid.dat.gz': require('kuromoji-react-native/dict/tid.dat.gz'),
  'tid_pos.dat.gz': require('kuromoji-react-native/dict/tid_pos.dat.gz'),
  'tid_map.dat.gz': require('kuromoji-react-native/dict/tid_map.dat.gz'),
  'cc.dat.gz': require('kuromoji-react-native/dict/cc.dat.gz'),
  'unk.dat.gz': require('kuromoji-react-native/dict/unk.dat.gz'),
  'unk_pos.dat.gz': require('kuromoji-react-native/dict/unk_pos.dat.gz'),
  'unk_map.dat.gz': require('kuromoji-react-native/dict/unk_map.dat.gz'),
  'unk_char.dat.gz': require('kuromoji-react-native/dict/unk_char.dat.gz'),
  'unk_compat.dat.gz': require('kuromoji-react-native/dict/unk_compat.dat.gz'),
  'unk_invoke.dat.gz': require('kuromoji-react-native/dict/unk_invoke.dat.gz'),
};

export async function loadDictAssets() {
  await Asset.loadAsync(Object.values(DICT_ASSETS));
  const assetMap = {};
  for (const [name, mod] of Object.entries(DICT_ASSETS)) {
    assetMap[name] = Asset.fromModule(mod).localUri;
  }
  return assetMap;
}

3. Use the tokenizer

import kuromoji from 'kuromoji-react-native';
import { loadDictAssets } from './dict-assets'; // the file from step 2

const assetMap = await loadDictAssets();
const tokenizer = await kuromoji.builder({ dicPath: assetMap }).build();
const tokens = tokenizer.tokenize("すもももももももものうち");
console.log(tokens);

You can also pass a remote URL base path instead of an asset map:

const tokenizer = await kuromoji.builder({ dicPath: "https://cdn.example.com/dict/" }).build();

A callback-based API is also supported:

kuromoji.builder({ dicPath: assetMap }).build((err, tokenizer) => {
  // ...
});

API

The tokenize() function returns a JSON array:

[{
    "word_id": 509800,
    "word_type": "KNOWN",
    "word_position": 1,
    "surface_form": "黒文字",
    "pos": "名詞",
    "pos_detail_1": "一般",
    "pos_detail_2": "*",
    "pos_detail_3": "*",
    "conjugated_type": "*",
    "conjugated_form": "*",
    "basic_form": "黒文字",
    "reading": "クロモジ",
    "pronunciation": "クロモジ"
}]

See src/util/IpadicFormatter.js for the full definition.

Memory usage

Once loaded, the dictionary data uses ~40MB of RAM. This is fine for most apps: load the tokenizer once when needed and keep it in memory for the session.

License

Apache-2.0 (same as upstream kuromoji.js)