he (for “HTML entities”) is a robust HTML entity encoder/decoder written in JavaScript. It supports all standardized named character references as per HTML, handles ambiguous ampersands and other edge cases just like a browser would, has an extensive test suite, and — contrary to many other JavaScript solutions — he handles astral Unicode symbols just fine.
Inorder to install he library via npm,

he.encode(text,options) takes a string of text and encodes (by default) any symbols that aren’t printable ASCII symbols and &, <, >, ", ', and `, replacing them with character references.As long as the input string contains allowed code points only, the return value of this function is always valid HTML. Any (invalid) code points that cannot be represented using a character reference in the input are not encoded.
For example, suppose i need to display the post titles from wordpress backend to Nextjs frontend. If it is simply rendered, the apostrophe or special characters from backend will be displayed as hexadecimal values in front end.

But if we use the he libarary and encode the post titles, it will be displayed properly.

When this libarary is used to decode the post titles,
