Next.js Discord

Discord Forum

How to use dangerouslySetInnerHTML in a safer way in NextJs?

West African Lion posted this in #help-forum
Open in Discord
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';

0 Replies