React·100 questions

How to protect against XSS in React?

Answer
React escapes strings by default.
It is dangerous to use dangerouslySetInnerHTML.
Sanitize HTML with DOMPurify.
Do not insert raw user input into HTML.
CSP and secure headers are also important.
Was this answer helpful?

More questions in this topic

Related questions from other topics