prism-react-renderer

A lightweight, themeable Prism syntax highlighter for React and React Native, built on a render-props API.

Library
npm
v2.4.1
1,995 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
49 /100 Fair
Development Activity 0
Maintenance 32
Community 64
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
83 /100 Excellent
Architecture 78
Code Quality 80
Innovation 88
Learning Curve 85

prism-react-renderer is a lean React component that tokenizes source code with a vendored, sandboxed copy of Prism and hands you the resulting tokens through a render-props API. Instead of shipping opinionated markup, it gives you tokens, getLineProps, and getTokenProps so you decide exactly how highlighted code is rendered — as <pre>/<span> trees, custom components, or even React Native views.

It ships with over twenty VSCode-inspired themes out of the box and a typed theming format that composes cleanly with SSR and static site generators, which is why it powers syntax highlighting inside Docusaurus and a wide range of other documentation tooling.

What You Get

  • A <Highlight> render-props component that returns tokens plus getLineProps/getTokenProps prop getters
  • A vendored, sandboxed Prism build that doesn’t pollute window.Prism, plus an escape hatch to bring your own Prism instance
  • 20+ built-in VSCode-style themes (Dracula, Night Owl, GitHub, One Dark, and more) with a typed theming format
  • Cross-platform support for React DOM and React Native from the same API
  • Utility exports (useTokenize, normalizeTokens) for building custom highlighting UIs

Common Use Cases

  • Rendering syntax-highlighted code blocks in documentation sites and MDX content (it’s the highlighter behind Docusaurus)
  • Building custom code-block components for blogs, changelogs, or in-app code viewers
  • Adding live, theme-aware code previews to design systems and component playgrounds
  • Highlighting code snippets inside React Native apps where DOM-based highlighters don’t work

Under The Hood

Architecture - The library is a thin, layered wrapper around Prism: the public Highlight component in index.ts injects default prism/theme props and delegates to an internal Highlight (components/highlight.ts), which resolves a theme dictionary via themeToDict, tokenizes the code with the useTokenize hook, and returns a render-props payload (tokens, className, style, getLineProps, getTokenProps) for the caller’s children function to render. useTokenize (components/useTokenize.ts) memoizes on code/grammar/language/prism, runs Prism’s before-tokenize/after-tokenize hooks, and passes raw Prism output through normalizeTokens (utils/normalizeTokens.ts), a non-recursive stack-based walker that flattens Prism’s nested token tree into Token[][] grouped by line, guarding against call-stack overflow on deeply nested grammars.

Tech Stack - Written in TypeScript, built as a pnpm workspace (packages/prism-react-renderer, packages/generate-prism-languages, packages/demo) with tsup for bundling to CJS/ESM/.d.ts, vitest for tests, and changesets for release management. It vendors and patches prismjs@1.29.0 (see patches/prismjs@1.29.0.patch) and depends only on clsx and @types/prismjs at runtime, with react as a peer dependency (>=16.0.0) so it stays framework-version-agnostic.

Used by 55 apps in this directory

TypeScript
95%
MIT

Actual

Invoicing Finance

29,186

Local-first personal finance with envelope budgeting, end-to-end encryption, and multi-device sync — no subscription required.

View details
93
Repo Health
85
Technical
73
Dependency
Built with
TypeScript 95%
Updated 4 days ago
TypeScript
56%
Other

agenta

AI Development · Developer Tools · Devops

4,788

The open-source LLMOps platform unifying prompt engineering, evaluation, and observability for teams building reliable LLM applications.

View details
91
Repo Health
77
Technical
67
Dependency
Built with
TypeScript 56%
Python 39%
Updated 5 days ago
Python
47%
Other

Airbyte

Data Engineering · Developer Tools

22,143

Open-source ELT platform with 600+ connectors for moving data from any source to warehouses, lakes, and AI agents.

View details
95
Repo Health
80
Technical
67
Dependency
Built with
Python 47%
Kotlin 43%
Updated 4 days ago
Python
55%
Other

authentik

Authentication · Security

25,758

The self-hosted Identity Provider that replaces Okta, Auth0, and Entra ID with a unified SSO platform supporting SAML, OAuth2/OIDC, LDAP, RADIUS, and WebAuthn.

View details
92
Repo Health
81
Technical
66
Dependency
Built with
Python 55%
TypeScript 36%
Updated 4 days ago
TypeScript
99%
Apache 2.0

Bubble Lab

AI Development · Automation

1,094

Open-core workflow engine for building AI-powered automations in TypeScript that run natively inside Slack — no context switching required.

View details
35
Repo Health
78
Technical
71
Dependency
Built with
TypeScript 99%
Updated 5 months ago
JavaScript
90%
Other

CodeSandbox

Code Editors · Developer Tools

13,650

Instantly ready browser-based IDE that runs full npm dependency resolution and transpilation entirely client-side, with no server needed.

View details
67
Repo Health
76
Technical
62
Dependency
Built with
JavaScript 90%
Updated 3 weeks ago
TypeScript
45%
Other

Convex Backend

Databases · Developer Tools

12,617

Open-source reactive database that lets developers build live-updating apps with pure TypeScript, strong consistency, and real-time subscriptions—no separate API layer required.

View details
87
Repo Health
82
Technical
68
Dependency
Built with
TypeScript 45%
Rust 43%
Updated 6 days ago
Go
64%
Apache 2.0

Coroot

Analytics · Monitoring

7,940

eBPF-powered observability with AI root cause analysis — zero code changes required, full-stack visibility out of the box.

View details
88
Repo Health
80
Technical
66
Dependency
Built with
Go 64%
Vue 34%
Updated 1 weeks ago
PHP
82%
MIT

Databasement

Databases · Developer Tools · Devops

2,468

Self-hosted database backup manager with a web UI for scheduling, encrypting, and restoring MySQL, PostgreSQL, MongoDB, SQL Server, SQLite, Firebird, and Redis to S3, SFTP, Samba, or local storage.

View details
82
Repo Health
77
Technical
69
Dependency
Built with
PHP 82%
Blade 16%
Updated 5 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers