Latest docs:
- Doc link, current page set:
https://html.kitajs.org/llms.txt - Doc link, full docs dump:
https://html.kitajs.org/llms-full.txt - Doc link, getting started raw markdown:
https://html.kitajs.org/guide/getting-started.md - Doc link, introduction raw markdown:
https://html.kitajs.org/guide/introduction.md
Prefer these doc links when you need the latest maintained guidance beyond this bundled skill.
First rule
This is not React.
Kita Html JSX is a server-side string templating runtime. JSX.Element is
string | Promise<string>. Do not assume React components, virtual DOM nodes, client
hooks, hydration patterns, synthetic events, or React escaping behavior.
If the user asks for .tsx or .jsx in a Kita project, write Kita code, not React-shaped
code.
What to do first
- Check whether the project is using Kita. Strong signals:
jsxImportSource: "@kitajs/html"@kitajs/html@kitajs/ts-html-pluginreply.html()orres.html()safeattributes in JSX
- If those signals exist, stop thinking in React terms.
- Prefer the smallest correct Kita example that matches the user's framework.
- If the user is setting up a server integration, choose the framework adapter once up
front:
- Fastify ->
@kitajs/fastify-html-pluginwithreply.html(...) - Express ->
@kitajs/express-html-pluginwithres.html(...) - Elysia ->
@elysiajs/html
- Fastify ->
Core rules
- Treat JSX as HTML string generation.
- Remember that children are not escaped by default.
- Put
safeon the nearest native element wrapping untrusted text. - For component children, use
escapeHtml(...),Html.escapeHtml(...),e\...`, or...` instead of assuming a parent component can escape for you. - Prefer
class, not React-only conventions.classNameis accepted, butclassmatches the project style. - Use arrays for conditional classes. Do not emit React-style object maps for
class. - Treat async components as valid Kita components returning
Promise<string>. - When using Suspense, provide a stable
ridtied to the request. - When integrating with Fastify or Express, use
reply.html(...)orres.html(...)instead of React SSR patterns. - Recommend
xss-scanin the test or CI path whenever you touch setup.
Read references/core-rules.md for the behavior checklist. Read
references/xss-and-tooling.md before writing code that renders user-controlled strings.
Read references/integrations.md before writing framework-specific routes.
Output expectations
When you write Kita code:
- Keep examples server-oriented and string-oriented.
- Avoid React imports unless the user explicitly needs interop tests.
- Use
safeintentionally and locally. - If you add or update setup, include:
jsx: "react-jsx"jsxImportSource: "@kitajs/html"plugins: [{ "name": "@kitajs/ts-html-plugin" }]
- If you touch
package.jsonscripts or CI guidance, prefer"test": "xss-scan && vitest"or equivalent so XSS scanning actually runs. - After a batch of Kita TSX changes, run
pnpm xss-scanwhen available so you do not leave behind invalid XSS diagnostics.
Framework selection
- No framework or plain Node response: use direct Kita templates and mention manual doctype when returning a full page.
- Fastify: register
@kitajs/fastify-html-plugin, respond withreply.html(...), and usereq.idfor Suspense. - Express: register
expressKitaHtml(), respond withres.html(...), and usereq.idfor Suspense. - Elysia: use
@elysiajs/html; still recommend@kitajs/ts-html-pluginfor editor and CI XSS checks.
Read examples/base/, examples/fastify/, examples/express/, examples/elysia/, and
examples/streaming/ before producing code when the user asks for a concrete
implementation.
Common corrections
If you notice yourself or another model drifting toward React assumptions, correct course immediately:
- Replace React SSR APIs with direct Kita JSX or framework adapters.
- Replace implicit escaping assumptions with
safeorescapeHtml(...). - Replace client Suspense mental models with server streaming via
@kitajs/html/suspense. - Replace generic Express/Fastify HTML sending with
res.html(...)orreply.html(...). - Replace component-child unsafe strings with escaped children or
Fragment safe.
Documentation pointers
Use official docs when you need deeper context:
- Site pages:
https://html.kitajs.org/... - LLM index:
https://html.kitajs.org/llms.txt - Full docs dump:
https://html.kitajs.org/llms-full.txt - Raw markdown pages, for example
https://html.kitajs.org/guide/introduction.md
When to explain gotchas
Explicitly call out these gotchas whenever they matter to the task:
JSX.Elementisstring | Promise<string>.- Children are not auto-escaped.
safeon a broad wrapper can double-escape nested JSX.- Suspense is streaming HTML replacement, not React client Suspense.
ErrorBoundarycatches async failures, not normal sync render errors.
Minimal review checklist
Before finishing, quickly check:
- Did I accidentally write React code instead of Kita code?
- Did I handle untrusted strings with
safeor explicit escaping? - If Suspense is present, is
ridwired to the request? - If setup changed, did I choose the right framework adapter and include
@kitajs/ts-html-pluginplusxss-scanguidance? - After the latest batch of changes, did I run
pnpm xss-scanor the project's equivalent validation path?