useSanitizeContent
SSR-safe HTML sanitizer that strips XSS threats while preserving rich formatting.
5.9 KB
•Updated on September 3, 2026
Installation
Bash
pnpm dlx shadcn@latest add @spaceui/hooks-form-use-sanitize-contentUsage
Code
import { useSanitizeContent } from '@/hooks/use-sanitize-content'
const safeHtml = useSanitizeContent('<p>Safe content</p><script>alert(1)</script>')API Reference
Parameters / Props
| Parameter | Type | Default | Description |
|---|---|---|---|
input | string|{ description: string } | required | Dirty HTML. |
Return Value
| Return Type | Description |
|---|---|
string | Clean, XSS-safe HTML string. |