Next.js Discord

Discord Forum

html sanitizing library

Answered
`${ViNoS}` posted this in #help-forum
Open in Discord
Avatar
how to sanitize html in next? i tried DOMpurify but it's not working with next
Answered by `${ViNoS}`
at the end i found a library called xss, it works perfectly for my case since it's purely javascrpt functions and sanitization (i guess)
however i think this is not really secure (didn't read or test anything, just my personal opinion)
View full answer

3 Replies

Avatar
you need to give more info here. sanitise html for what? how did you use DOMpurify and why did it not work?
Avatar
yes i used DOMPurify
it did not work because it needs a DOM api to work with , this way it will error on the backend when pre-rendered (althought it gonna work but the page will be fully client side rendered, 0 html shipped )
you can make it work on the server side by using JSDom package, but then it won't work at all since JSDOM doesen't work client side
Avatar
at the end i found a library called xss, it works perfectly for my case since it's purely javascrpt functions and sanitization (i guess)
however i think this is not really secure (didn't read or test anything, just my personal opinion)
Answer