React Syntax Highlighter
react-syntax-highlighter
syntax highlighting component for react with prismjs or highlightjs ast using inline styles
Utilities
react
syntax
lowlight
highlighting
ast
react-syntax-highlighter
Utilities
javascript
npm
frontend
Stars
4.7k
Weekly
4.5M
Open issues
138
Bundle
~25 kB
Installation
npm install react-syntax-highlighterCode example
import { useSyntaxHighlighter } from "react-syntax-highlighter";
export function Example() {
const value = useSyntaxHighlighter();
return <p>{String(value)}</p>;
}Pros & cons
Pros
- Actively maintained by Conor Hastings
- 4.5M weekly downloads. Battle tested
- MIT licensed
Considerations
- Adds roughly ~25 kB to your bundle
- Needs client-only rendering in SSR frameworks
- Not supported in React Native
- 138 open issues on GitHub