Getting started
Estimated reading time: 2 minutesInstall @kitajs/html and @kitajs/html-cli together, with TypeScript 7.1 or later. The
first is the JSX runtime; the second provides kita-html check, which catches XSS at
compile time.
TypeScript 7.1 is published under the next tag until its stable release. Projects that
cannot leave TypeScript 6 yet can use the deprecated
editor plugin and xss-scan instead of @kitajs/html-cli.
TypeScript configuration
Add the following to your tsconfig.json. The jsx and jsxImportSource fields tell
TypeScript to compile JSX using the Kita Html runtime.
XSS scanner
Add kita-html check to your test script so it runs in CI alongside your tests. It type
checks every TSX file of the project and fails on any unsafe JSX.
TypeScript 7 does not load editor plugins, so findings appear in the terminal and CI.
kita-html check shows how to annotate GitHub pull requests and
list findings in the VS Code Problems panel.
Verification
Write the following in a .tsx file:
Run npx kita-html check. It reports TS88601 on String.name, because its type is
string and it is not escaped. If no error appears, verify that the file is included by
the tsconfig.json in the current directory, or pass the right config with -p.