React Syntax Highlighter
A React component for syntax-highlighting code blocks using highlight.js or Prism ASTs, with JavaScript-based styles and no external stylesheet required.
Repository Health
Technical Analysis
React Syntax Highlighter is a component library that renders syntax-highlighted code blocks inside React applications. Instead of manually manipulating the DOM in componentDidMount/componentDidUpdate and injecting HTML with dangerouslySetInnerHTML, it walks an abstract syntax tree produced by highlight.js (via lowlight) or Prism (via refractor) and builds it into the virtual DOM, so updates only touch the nodes that actually changed and the component works as an idiomatic, pure function component.
All bundled styles are plain JavaScript objects rather than CSS files, so consumers get out-of-the-box code theming without adding a stylesheet <link> tag — every highlight.js and Prism theme has been ported to JS. Teams that prefer CSS classes instead can opt out with useInlineStyles={false}. A “light build” variant lets consumers register only the specific languages and styles they need to keep bundle size down, and async variants defer loading the highlighting engine and language definitions via dynamic import() for faster first paint.
What You Get
- A default
SyntaxHighlightercomponent backed by highlight.js/lowlight, plus aPrismvariant backed by refractor for better JSX and TSX highlighting fidelity - Every highlight.js and Prism theme pre-ported to JavaScript style objects, importable directly from
react-syntax-highlighter/dist/esm/styles/{hljs|prism} Light/PrismLightbuilds that only bundle languages you explicitlyregisterLanguage(), keeping bundle size small for apps that only need a handful of languagesLightAsync/PrismAsyncLight/PrismAsyncvariants that dynamicallyimport()the highlighting engine and language grammars for faster initial page loads- Line-number rendering (
showLineNumbers,showInlineLineNumbers), custom line wrapping (wrapLines,wrapLongLines), and per-line prop injection (lineProps) for building diff- or annotation-style code views - A pluggable
rendererprop and customPreTag/CodeTagoverrides for non-DOM targets (e.g. virtualized lists, React Native renderers)
Common Use Cases
- Rendering highlighted code snippets inside documentation sites, blog posts, or MDX content
- Building an in-app code viewer/diff viewer for developer tools, IDE-in-the-browser products, or PR review UIs
- Displaying generated or example code inside a design-system playground, API reference, or interactive tutorial
- Presentation/slide tools (e.g. mdx-deck) and Electron-based documentation editors that need themeable code blocks without a CSS build step
Under The Hood
Architecture src/index.js exports a family of components — the default highlight.js-backed SyntaxHighlighter, Light/PrismLight register-only-what-you-use builds, and LightAsync/PrismAsync/PrismAsyncLight dynamic-import variants — all funneling into the ~440-line src/highlight.js, which walks the AST returned by lowlight (highlight.js) or refractor (Prism) and recursively converts it into React elements via create-element.js (~210 lines), handling line numbers, line wrapping, and custom renderers along the way. async-syntax-highlighter.js (~155 lines) wraps the synchronous highlighter so language/theme modules can be code-split, rendering plain unhighlighted text with line numbers as a fallback while the import resolves.
Tech Stack Plain JavaScript compiled with Babel (no TypeScript in the source; types ship separately via DefinitelyTyped’s @types/react-syntax-highlighter), dual-published as CJS and ESM (build:cjs/build:esm) plus a webpack UMD bundle. Highlighting is delegated to highlight.js/lowlight and prismjs/refractor, with highlightjs-vue covering Vue templates; React itself is only a peer dependency (>= 0.14.0), so the library stays agnostic to the consumer’s React version.
Code Quality 20 Jest test files under __tests__/ use react-test-renderer snapshots to cover the async, light, and Prism variants, line-number rendering, custom pre/code tags, line wrapping, and unusual inputs (unknown language, plain text, Vue). Coverage is broad but mostly snapshot-based rather than fine-grained behavioral assertions. ESLint, Prettier, and husky/lint-staged enforce style at commit time; per the health-score data, recent commit velocity is low relative to the project’s age despite fairly regular point releases.
API Design The public API is declarative and low-boilerplate — <SyntaxHighlighter language="js" style={theme}>{code}</SyntaxHighlighter> is enough to get syntax highlighting working, and switching highlighting engine or loading strategy (sync/light/async) is a matter of swapping the import rather than learning a new API. The README documents every prop in one place with live demo links, though supported languages/styles are discoverable only via separate markdown reference files rather than editor autocomplete in the base package.
Used by 59 apps in this directory
Mastra Code
AI Code Assistants
"A coding agent that never compacts" — a terminal-based AI coding agent built on the Mastra framework, with Observational Memory instead of context compaction, multi-model support, and OAuth login for Claude Max or ChatGPT Plus.
melty
AI Code Assistants · Code Editors · Developer Tools
The AI code editor where every chat message is a git commit you can revert, branch, or squash
MLflow
AI Development · Monitoring
The open source AI engineering platform for debugging, evaluating, monitoring, and optimizing production LLMs and agents at scale.
Morphik
AI Development · Databases · Search
Morphik is an AI-native ingestion and retrieval engine that lets developers store, search, and reason over visually rich documents — scanned PDFs, manuals, slides, and video — without duct-taping together OCR, an embedding model, and a vector database.
nao
AI Development · Analytics
Build and deploy an open-source analytics agent that understands your data warehouse and answers business questions in plain English.
NocoBase
Low Code Platforms · No Code Platforms
Open-source AI + no-code platform that lets coding agents and people collaborate to build business systems fast on proven infrastructure.
OneUptime
Monitoring
The complete open-source observability platform that replaces PagerDuty, Datadog, Sentry, and StatusPage with a single self-hostable system.
Onlook
AI Design Tools · Design Tools
An open-source, AI-first visual editor that lets designers and developers build, style, and deploy React apps directly in code — no handoff required.
Open Lovable
AI Development
An open-source AI app builder that scrapes a live website and recreates it as a modern React app through chat — built by Firecrawl as a self-hostable example of the Lovable.dev workflow.