jsx-runtime.ts

Source

17 documented symbols. Read the signatures first, then expand each item for parameters, return types, and examples.

17 symbols 11 functions 2 interfaces 2 types 1 variables 1 modules 19 parameters 3 members 11 returns 5 examples

Reference

fneach<T>(items: T[], render: (item: T, index: number) => JSXNode): JSXNodeMaps over an array and renders each item.

Maps over an array and renders each item.

Signature

export function each<T>(items: T[], render: (item: T, index: number) => JSXNode): JSXNode

View source

Parameters

Returns

JSXNode

Examples

Example 1
{each(items, (item) => <li>{item.name}</li>)}
fnescapeHtml(str: string): stringEscapes HTML special characters to prevent XSS.

Escapes HTML special characters to prevent XSS.

Signature

function escapeHtml(str: string): string

View source

Parameters

  • str string

Returns

string
fnFragment({ children }: { children?: JSXChild }): JSXNodeFragment component - renders children without a wrapper element.

Fragment component - renders children without a wrapper element.

Signature

export function Fragment({ children }: { children?: JSXChild }): JSXNode

View source

Parameters

Returns

JSXNode
fnjsx(type: JSXElementType, props: JSXProps, _key?: string): JSXNodeCreates a JSX element. This is the core function called by the JSX transform.

Creates a JSX element. This is the core function called by the JSX transform.

Signature

export function jsx(type: JSXElementType, props: JSXProps, _key?: string): JSXNode

View source

Parameters

Returns

JSXNode
modulejsx-runtimeCustom JSX Runtime for Static HTML Generation This module provides a JSX runtime that outputs static HTML strings. No R…

Custom JSX Runtime for Static HTML Generation

This module provides a JSX runtime that outputs static HTML strings. No React, no hydration, no client-side JavaScript - just pure HTML.

View source

Examples

Example 1
// tsconfig.json or vite.config.ts
{
  "compilerOptions": {
    "jsx": "react-jsx",
    "jsxImportSource": "@ox-content/vite-plugin"
  }
}

typeJSXChild = string | number | boolean | null | undefined | JSXNode | JSXChild[]Valid JSX child types.

Valid JSX child types.

Signature

export type JSXChild = string | number | boolean | null | undefined | JSXNode | JSXChild[]

View source

typeJSXElementType = string | ((props: Record<string, unknown>) => JSXNode)JSX element type - either a string (intrinsic) or a function component.

JSX element type - either a string (intrinsic) or a function component.

Signature

export type JSXElementType = string | ((props: Record<string, unknown>) => JSXNode)

View source

interfaceJSXNodeJSX node - the result of JSX expressions.

JSX node - the result of JSX expressions.

Signature

export interface JSXNode

View source

Members

Properties
NameTypeDescription
__html string
interfaceJSXPropsProps with children.

Props with children.

Signature

export interface JSXProps

View source

Members

Indexable
[key: string]: unknown
Properties
NameTypeDescription
childrenoptional JSXChild
fnjsxs(type: JSXElementType, props: JSXProps, key?: string): JSXNodeCreates a JSX element with static children. Called by the JSX transform for ele…

Creates a JSX element with static children. Called by the JSX transform for elements with multiple children.

Signature

export function jsxs(type: JSXElementType, props: JSXProps, key?: string): JSXNode

View source

Parameters

Returns

JSXNode
fnraw(html: string): JSXNodeCreates raw HTML without escaping. Use with caution - only for trusted content.

Creates raw HTML without escaping. Use with caution - only for trusted content.

Signature

export function raw(html: string): JSXNode

View source

Parameters

  • html string

Returns

JSXNode

Examples

Example 1
<div>{raw('<strong>Bold</strong>')}</div>
fnrenderAttr(name: string, value: unknown): stringRenders an attribute value to a string.

Renders an attribute value to a string.

Signature

function renderAttr(name: string, value: unknown): string

View source

Parameters

  • name string
  • value unknown

Returns

string
fnrenderChildren(children: JSXChild): stringRenders children to HTML string.

Renders children to HTML string.

Signature

function renderChildren(children: JSXChild): string

View source

Parameters

Returns

string
fnrenderToString(node: JSXNode): stringRenders a JSX node to an HTML string.

Renders a JSX node to an HTML string.

Signature

export function renderToString(node: JSXNode): string

View source

Parameters

Returns

string
fntoHtmlAttr(name: string): stringConverts a camelCase attribute name to kebab-case for HTML. Special handling fo…

Converts a camelCase attribute name to kebab-case for HTML. Special handling for data- and aria- attributes.

Signature

function toHtmlAttr(name: string): string

View source

Parameters

  • name string

Returns

string
variableconst VOID_ELEMENTS = new Set([ "area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "param", "source", "track", "wbr", ])Custom JSX Runtime for Static HTML Generation This module provides a JSX runtim…

Custom JSX Runtime for Static HTML Generation

This module provides a JSX runtime that outputs static HTML strings. No React, no hydration, no client-side JavaScript - just pure HTML.

Signature

const VOID_ELEMENTS = new Set([
  "area",
  "base",
  "br",
  "col",
  "embed",
  "hr",
  "img",
  "input",
  "link",
  "meta",
  "param",
  "source",
  "track",
  "wbr",
])

View source

Examples

Example 1
// tsconfig.json or vite.config.ts
{
  "compilerOptions": {
    "jsx": "react-jsx",
    "jsxImportSource": "@ox-content/vite-plugin"
  }
}

fnwhen(condition: boolean, content: JSXNode): JSXNodeConditionally renders content.

Conditionally renders content.

Signature

export function when(condition: boolean, content: JSXNode): JSXNode

View source

Parameters

  • condition boolean
  • content JSXNode

Returns

JSXNode

Examples

Example 1
{when(isLoggedIn, <UserMenu />)}