Idea Cheerio brings jQuery for the NodeJS without browser Cheerio parses markup and provides an API for traversing/manipulating the resulting data structure Installation npm i cheerio Example
import * as cheerio from 'cheerio'
function Component(props) {
const ref = useRef()
const addHeading = () => {
const $ = cheerio.load('<h2 class="title">Hello world</h2>')
$('h2.title').text('Heading')
$.html()
ref.current.innerHTML = $.html()
}
return (
<>
<button onClick={addHeading}>add heading</button>
<div ref={ref}>text in div</div>
</>
)
}