Function: expressKitaHtml()

Estimated reading time: less than 1 minute
function expressKitaHtml(opts): RequestHandler

The @kitajs/express-html-plugin middleware.

It decorates res.html(), optionally assigns req.id, and enables Suspense streaming by matching that request id with Suspense rid={req.id}.

Parameters

opts

NonNullable<Partial<ExpressKitaHtmlOptions>> = {}

Returns

RequestHandler

Example

import express from 'express'
import { expressKitaHtml } from '@kitajs/express-html-plugin'

const app = express()

app.use(expressKitaHtml())

app.get('/', (req, res) => {
  res.html(
    <html lang="en">
      <body>
        <h1>Hello, world!</h1>
      </body>
    </html>
  )
})