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
733
Weekly
6.6M
Open issues
9
Bundle
~15 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
- 6.6M weekly downloads. Battle tested
- MIT licensed
Considerations
- Adds roughly ~15 kB to your bundle
- Needs client-only rendering in SSR frameworks
- Not supported in React Native
- 9 open issues on GitHub