On this pageReactUtilsModule OverviewWhile optional, Keywork uses React as its primary HTML templating engine.Peer DependenciesIf you haven't already, make sure to add the React peer dependencies:YarnNPMDenoRun in the root of your project.$ yarn add react react-domRun in the root of your project.$ npm install --save react react-domImport Maps are recommended to avoid long import URLs:./your-project/import_map.json{ "imports": { "react": "https://esm.sh/[email protected]", "react-dom": "https://esm.sh/[email protected]", "react-dom/client": "https://esm.sh/[email protected]/client", "react-dom/server": "https://esm.sh/[email protected]/server", "react-dom/server.browser": "https://esm.sh/[email protected]/server.browser", "react/jsx-runtime": "https://esm.sh/react/jsx-runtime" }}UsageRoute 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 appUsageNodeDenoBrowser/ESMimport * as ReactUtils from 'keywork/react'import * as ReactUtils from 'https://deno.land/x/keywork/react'let ReactUtils = await import('https://esm.sh/keywork/react')InterfacesReactRendererOptions
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:
Import Maps are recommended to avoid long import URLs:
Usage
Route handlers defined on an instance of
RequestRouter
can return a React component, Keywork automatically converts the content into a streamed response.