Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 5 additions & 18 deletions content/blog_posts/articles/use-tsx-for-your-template-engine.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,38 +84,25 @@ export function Header() {

I have tried different packages to use TSX as a templating engine. For this tutorial, we will use [`@kitajs/html`](https://github.com/kitajs/html), but feel free to use the one you prefer.

First, you have to install the package. At the time of writing, this package is at version `3.1.1`.
First, you have to install the package. At the time of writing, this package is at version `4.1.0`.

We will also install their plugin to enable editor intellisense.

```sh
npm install @kitajs/html @kitajs/ts-html-plugin
```

Once done, we will edit the `bin/server.ts` file to register Kita.

```ts
import 'reflect-metadata'
// insert-start
import '@kitajs/html/register.js'
// insert-end
import { Ignitor, prettyPrintError } from '@adonisjs/core'

// ...
```

We must also change our `tsconfig.json` file to add JSX support.
Once done, will edit the `tsconfig.json` file to add JSX support.

```js
{
// ...
"compilerOptions": {
// ...
// insert-start
"jsx": "react",
"jsxFactory": "Html.createElement",
"jsxFragmentFactory": "Html.Fragment",
"plugins": [{ "name": "@kitajs/ts-html-plugin" }]
"jsx": "react-jsx",
"jsxImportSource": "@kitajs/html",
"plugins": [{ "name": "@kitajs/ts-html-plugin" }]
// insert-end
}
}
Expand Down