An open API service indexing awesome lists of open source software.

https://github.com/jozefini/codesync-kses

Equivalent helper `wp_kses` written in JavaScript
https://github.com/jozefini/codesync-kses

html sanitizer xss

Last synced: 7 months ago
JSON representation

Equivalent helper `wp_kses` written in JavaScript

Awesome Lists containing this project

README

          

### Equivalent of `wp_kses` / `wp_kses_post` in JavaScript/Node.js

Safely render HTML in React or any other JavaScript environment.
Works in both Node.js and the browser.

#### Example JavaScript

```typescript
import { kses } from '@codesync/kses'

const unsafeHtml = 'Test parseralert("hello")'
const safeHtml = kses(unsafeHtml)
// Output: Test parser
```

#### Example React

```typescript
'use client'
import { kses } from '@codesync/kses'

export default function ClientPage() {
const unsafeHtml =
'Test parseralert("hello")'
const safeHtml = kses(unsafeHtml)

// Output:

Test parser

return

}
```

#### Example RSC

```typescript
import { kses } from '@codesync/kses/server'

export default function ServerPage() {
const unsafeHtml =
'Test parseralert("hello")'
const safeHtml = kses(unsafeHtml)

// Output:

Test parser

return

}
```