High-performance syntax highlighting for React Native.
Note: This library is currently in active development, porting to New Architecture, Bridgeless, and
Nitro Modules.
Note: Minimum supported version of React Native is
0.75.
Unlike other JS-based syntax highlighters, react-native-libprisma is powered by a C++ port of Prism.js using JSI, providing much greater performance - especially on mobile devices.
- 🏎️ Blazing Fast - C++ implementation with native performance via JSI
- ⚡️ Zero Dependencies - No dependencies on C++ or TypeScript layers
- 🧪 200+ Languages - Comprehensive language support out of the box
- 🎨 11 Built-in Themes - Beautiful, ready-to-use themes (Dracula, VS Code, etc.)
- 🔢 TypeScript First - Full type safety with autocomplete
- 🔁 Cross Platform - Works on iOS, Android, and macOS
| Version | RN Architecture | Modules |
|---|---|---|
0.4.x + |
New / Bridgeless | Nitro Modules |
<= 0.3.x |
Old / New | Turbo Modules |
This library is significantly faster than JS-only alternatives because the tokenization happens in C++. See Benchmarks for detailed comparisons.
bun add react-native-libprisma react-native-nitro-modules
cd ios && pod installnpx expo install react-native-libprisma
npx expo prebuildimport { tokenize } from 'react-native-libprisma';
const code = `const greeting = "Hello, World!";`;
const tokens = tokenize(code, 'javascript');import { tokenize, themes } from 'react-native-libprisma';
import { Text } from 'react-native';
function CodeBlock() {
const code = `console.log("Hello!");`;
const tokens = tokenize(code, 'javascript');
const theme = themes.draculaTheme;
return (
<Text>
{tokens.map((token, i) => (
<TokenDisplay key={i} token={token} theme={theme} />
))}
</Text>
);
}We include 11 popular themes out of the box:
import { themes } from 'react-native-libprisma';
themes.draculaTheme // Dracula
themes.peaceOfEyeTheme // Default Dark
themes.officialTheme // VS Code Dark
themes.blueVelvetTheme // Blue Velvet
themes.vintageTheme // Vintage
themes.shadesOfGreyTheme // Shades of Grey
themes.traditionalTheme // Traditional
themes.professionalTheme // Professional
themes.defaultColorTheme // Default
themes.peaceOfEyeDraculaTheme // Peace of Eye (Dracula variant)
themes.simpleAsLightTheme // Light ThemeJoin the Margelo Community Discord to chat about react-native-libprisma or other libraries.
See the contributing guide to learn how to contribute to the repository and the development workflow.
- react-native-libprisma is licensed under MIT.
- This project builds upon the excellent work of Telegram's libprisma and Prism.js.
- Special thanks to LearnWithSumit for VSCode theme inspiration.
Built with ❤️ by Athex Web3