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

@discord/markdown-react-native

v0.2.2

Published

React Native (JSI) bindings for parsing Discord Markdown

Readme

markdown-react-native

React Native bindings for the Discord Markdown parser (@discord/markdown-react-native), implemented as a pure C++ TurboModule. The Rust parser is compiled to a static library (ffi/c) and linked into a single C++ module (cpp/NativeDiscordMarkdown.cpp) that both platforms share; there is no per-call bridge traffic and no platform-specific parser code.

Requires the New Architecture (React Native 0.77+).

Usage

import { parse } from "@discord/markdown-react-native";

const blocks = parse("# Hello **world**");
// [{ type: "heading", value: { level: 1, content: [...] } }]

// Optionally restrict which rules parse:
const restricted = parse("**bold** _italic_", ["bold"]);

parse runs synchronously on the JS thread and returns the same typed AST (Block[] from @discord/markdown-types) as the wasm binding, so rendering code can be shared between web and native. Snowflake IDs and timestamp values are BigInts, also matching the wasm binding.

How it works

  • src/NativeDiscordMarkdown.ts is the TurboModule spec; codegen (configured through codegenConfig in package.json) generates the typed C++ base class NativeDiscordMarkdownCxxSpec.
  • cpp/NativeDiscordMarkdown.cpp implements the spec by calling the Rust parser's C ABI (dmd_parse). parseToAstString is a synchronous JSI method — no bridge, no async hop.
  • Registration is declarative, with no app changes required:
  • The JS wrapper decodes the returned JSON. 64-bit integers cross the boundary as {"$bigint": "…"} wrappers (see ffi/c/src/bigint.rs) and are revived as BigInts, since a plain JSON.parse would corrupt them as float64s.

Building

Inside this repo, the native builds drive cargo themselves; consumers from npm receive the Rust parser prebuilt (android/prebuilt/, ios/DiscordMarkdownC.xcframework), built at publish time.

Android (Gradle runs cargo-ndk for armeabi-v7a, arm64-v8a, x86, and x86_64, or the subset in reactNativeArchitectures):

rustup target add aarch64-linux-android armv7-linux-androideabi i686-linux-android x86_64-linux-android
cargo install cargo-ndk

iOS (the example app's Podfile runs ios/build-rust.sh, which also assembles the vendored xcframework; re-run it after changing the parser):

rustup target add aarch64-apple-ios aarch64-apple-ios-sim x86_64-apple-ios

JS tests (the decoding layer; the native layer is tested in cargo test -p discord-markdown-c):

pnpm test

Example app

example/ is a React Native playground app (a workspace package, like site for web): a live markdown → AST view over the native parser, for manual verification and development. From the repo root:

pnpm install
cd lib/react-native/example
pnpm android                       # or open example/android in Android Studio
cd ios && bundle exec pod install  # then: pnpm ios, or open MarkdownExample.xcworkspace

End-to-end tests

The e2e_react_native CI jobs build the example app for release on both platforms — exercising codegen, autolinking, and the in-repo Rust builds — then drive it on an Android emulator and an iOS simulator with Maestro (example/.maestro/parse.yaml), asserting on the AST the app renders: default content parses to a heading with a full-precision BigInt mention id, and typed content re-parses live. They then pack the npm tarball and assert the prebuilt Rust artifacts ship in it. The same flow runs locally with maestro test -e APP_ID=… .maestro/parse.yaml against any running emulator or simulator.

Known limitations

  • New Architecture only. On the old architecture TurboModuleRegistry.getEnforcing throws at import time.
  • Worklet runtimes (Reanimated, etc.) are separate JSI runtimes; parse is only callable from the main JS runtime.