Skip to main content

ReactUtils

Module Overview

While optional, Keywork uses React as its primary HTML templating engine.

Peer Dependencies

If you haven't already, make sure to add the React peer dependencies:

Run in the root of your project.
$ yarn add react react-dom

Usage

Route handlers defined on an instance of RequestRouter can return a React component, Keywork automatically converts the content into a streamed response.

import { RequestRouter } from 'keywork/router'

const app = new RequestRouter()

app.get('/', () => <h1>Hello from Keywork! 👋</h1>)

interface GreetParams {
firstName: string
}

app.get('/greet/:firstName', ({ params }) => {
return (
<div>
<h1>Hello there! {params.firstName}</h1>
</div>
)
})

export default app

Usage

import * as ReactUtils from 'keywork/react'

Enumerations

Interfaces

Type Aliases

Variables

Functions