Issues in fetching special characters in Next Js / React.

Sometimes situations can be risen in fetching special characters into the website when working with latest frontend technologies like react, Vue js , next js etc.

It’s must that we have to deal with these issues.

A library called “He” could be a better solution in this situation.

The “He” library is typically used for HTML entity encoding in JavaScript. In a Next.js project, you can install the “he” library using npm or yarn. To install “he” is using npm, run the following command in your Next.js project directory.

npm install he

If you’re using yarn, you can use:

yarn add he

Once you’ve installed the “he” library, you can use it in your Next.js components or pages by importing it like this:

import he from 'he';

// Example usage:
const encodedString = he.encode('Some <b>HTML</b> entities');
console.log(encodedString);

This will encode HTML entities in the given string.

Leave a comment

Your email address will not be published. Required fields are marked *