Next.js Discord

Discord Forum

How to use dangerouslySetInnerHTML in a safer way in NextJs?

Unanswered
West African Lion posted this in #help-forum
Open in Discord
Avatar
West African LionOP
I used dangerouslySetInnerHTML in page.tsx , it rendered the page the way I want it to but it gave Hydration error in the console. So, I used a package called "html-react-parser", Now the errors are gone but my team lead is saying that it is still exposing the app to XSS attacks. How can I rectify this? PFA for how I am using the html-react-parser. Here Parser is : import Parser from 'react-html-parser';
Image

0 Replies