TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/elysiajs/documentation/llms.txt
Use this file to discover all available pages before exploring further.
@elysia/html plugin lets you return JSX components and HTML strings from Elysia handlers. It automatically sets Content-Type: text/html; charset=utf8, prepends <!doctype html> where needed, and converts the result to a proper Response.
Installation
Basic usage
JSX setup
The HTML plugin is based on @kitajs/html, which compiles JSX to strings at build time for high performance.XSS protection
The plugin uses @kitajs/html which detects possible XSS vulnerabilities at compile time. Use thesafe attribute to sanitize user-supplied values:
tsconfig.json:
Options
contentType
Default: 'text/html; charset=utf8'
The Content-Type header value set on HTML responses.
autoDetect
Default: true
When true, the plugin inspects returned strings and sets the Content-Type header automatically when HTML is detected.
autoDoctype
Default: true
When true, prepends <!doctype html> to responses that start with <html> but don’t already include a doctype. Set to 'full' to also add doctypes to HTML responses returned without the plugin.
isHtml
Type: (value: string) => boolean
Custom function to determine whether a string value is HTML. The default implementation returns true when the string is longer than 7 characters, starts with <, and ends with >.