About the Project
@neeleshyadav/react-native-html-renderer is a modern, TypeScript-first replacement for the abandoned react-native-render-html. It parses HTML strings and renders them as 100% native React Native components — no WebView, no iframe, no hidden DOM. The library is actively maintained, lightweight, and ships with sensible defaults around security, accessibility, and theming.
The architecture is modular: a parser built on htmlparser2 with LRU caching, a sanitiser layer that strips dangerous tags and URL schemes by default, a styles module that handles CSS → StyleSheet conversion plus cascade ordering, and a renderer layer with per-node error boundaries so a single failing tag never collapses the tree. A context provider propagates shared config (contentWidth, styles, colorScheme) to custom renderers and hooks.
Security is enabled by default: script, iframe, object, embed, form, svg, and math tags are stripped; any on* event-handler attribute is blocked; javascript:, vbscript:, and data:text/html URLs are rejected; URL attributes are normalised to strip control-character bypasses; and prototype-pollution attempts (__proto__, constructor, prototype) are rejected at the attribute level. A max DOM depth of 100 prevents stack-overflow attacks from deeply nested input.
Dark mode is automatic via useColorScheme() with per-tag overrides available through darkModeStyles, and font scaling respects system accessibility settings with an optional maxFontSizeMultiplier cap. ARIA attributes map into React Native's accessibility props — aria-label, aria-hidden, aria-role, aria-disabled/checked/expanded/busy/selected — so screen readers work out of the box.
Performance is driven by two LRU caches: 50 parsed DOM trees and 200 image dimensions (keyed to avoid cache poisoning across allowDangerousHtml / ignoredTags permutations). Custom renderers receive a full context (node, children, merged style, attributes, passProps, renderChildren, contentWidth) so consumers can override any tag. The project ships with ~118 Jest tests across 7 suites covering parsing, sanitising, caching, styles, accessibility, and rendering.
Key Highlights
Technical Breakdown
Feature areas & implementation details