https://github.com/ssi02014/react-sanitizer-parser
react-sanitizer-parser is a React element sanitizer parser.
https://github.com/ssi02014/react-sanitizer-parser
dompurify html-react-parser parser react xss
Last synced: 2 months ago
JSON representation
react-sanitizer-parser is a React element sanitizer parser.
- Host: GitHub
- URL: https://github.com/ssi02014/react-sanitizer-parser
- Owner: ssi02014
- Created: 2023-08-09T01:53:46.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2023-08-09T17:58:13.000Z (about 2 years ago)
- Last Synced: 2025-06-25T04:18:46.752Z (3 months ago)
- Topics: dompurify, html-react-parser, parser, react, xss
- Language: TypeScript
- Homepage: https://github.com/ssi02014/react-sanitizer-parser
- Size: 2.73 MB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 💻 react-sanitizer-parser
react-sanitizer-parser is a React element sanitizer parser that utilizes the [html-react-parser](https://github.com/remarkablemark/html-react-parser) and [dompurify](https://github.com/cure53/DOMPurify) libraries.
## install
```
npm install react-sanitizer-parser
```
```
yarn add react-sanitizer-parser
```## Usage
```tsx
import ReactSanitizerParser from "react-sanitizer-parser";const Example = () => {
const dirty = `
React Sanitizer Parser
`;return (
{dirty}
);
}
```### htmlParserOptions & sanitizerConfig
- [html-react-parser Options](https://github.com/remarkablemark/html-react-parser#usage)
- [DOMPurify Config](https://github.com/cure53/DOMPurify#can-i-configure-dompurify)```tsx
import ReactSanitizerParser from "react-sanitizer-parser";const Example = () => {
const dirty = `
React Sanitizer Parser
`;return (
{dirty}
);
}
```### parse, DOMPurify
If you need to, you can use the `parse` method of html-react-parser and DOMPurify's `DOMPurify` directly.```tsx
import ReactSanitizerParser, { parse, DOMPurify } from "react-sanitizer-parser";function App() {
console.log(DOMPurify.sanitize("")); //
![]()
return (
<>
{parse("React")}
{`React`}
>
);
}
```