# songstress/ui/jsx-runtime

> What a .tsx file's JSX compiles to, with jsxImportSource songstress/ui, and the JSX types of client code.

Page: https://songstress.app/docs/develop/reference/jsx-runtime/

A `.tsx` file whose `jsxImportSource` is `songstress/ui` (the starter's `tsconfig.json` says so, and
`songstress build` assumes it with no `tsconfig.json` at all) compiles each element to `jsx` from this entry. Its
`JSX` namespace is the types of client code: a tag is one of [`songstress/ui`](/docs/develop/reference/ui/)'s
components or one of your own, never a lower-case name, and a handler may be a function. You never import this
entry yourself; the compiler and the bundler do.

`songstress/ui/jsx-dev-runtime` is what a development build (Vitest, an editor's preview) imports in its place, with
the same elements.

### Fragment

Groups children without a node of its own.

```ts
export declare const Fragment: (props: {
    children?: UiNode;
}) => UiElement;
```

Refers to [UiNode](/docs/develop/reference/ui/#type-UiNode), [UiElement](/docs/develop/reference/ui/#type-UiElement).

### JSX

The JSX of client code: a tag is a component, never a lower-case name;
a handler may be a function.

```ts
export declare namespace JSX {
    type Element = UiElement;
    type ElementType = (props: never) => UiNode | Screen | PanelContent | StatusContent;
    interface ElementChildrenAttribute {
        children: unknown;
    }
    interface IntrinsicAttributes {
        key?: string | number;
    }
    interface IntrinsicElements {
    }
}
```

Refers to [UiElement](/docs/develop/reference/ui/#type-UiElement), [UiNode](/docs/develop/reference/ui/#type-UiNode), [Screen](/docs/develop/reference/songstress/#type-Screen), [PanelContent](/docs/develop/reference/songstress/#type-PanelContent), [StatusContent](/docs/develop/reference/songstress/#type-StatusContent).

### jsx

The JSX factory: what a `.tsx` file compiles each element to, with
`jsxImportSource` `songstress/ui` (or `songstress/ui/server` for server
code). A tag is a component of `songstress/ui` or one of the author's own,
never a lower-case name.

```ts
export declare function jsx(type: unknown, props: Record<string, unknown> | null, key?: string | number): UiElement;
```

| Parameter | Type | Description |
|---|---|---|
| `type` | `unknown` | The component. |
| `props` | `Record<string, unknown> \| null` | Its props, `children` among them. |
| `key?` | `string \| number` | Its JSX `key`: the node's `key` on the wire. |

Returns `UiElement`.

Example:

```ts
import { jsx } from 'songstress/ui/jsx-runtime'
import { Text } from 'songstress/ui'

// What `<Text style="title">Played lately</Text>` compiles to.
const title = jsx(Text, { style: 'title', children: 'Played lately' })
```

Refers to [UiElement](/docs/develop/reference/ui/#type-UiElement).

### jsxs

The JSX factory of an element with several children, which a compiler
tells apart from `jsx`: here they are one function.

```ts
export declare const jsxs: typeof jsx;
```

Refers to [jsx](/docs/develop/reference/jsx-runtime/#type-jsx).

It also exports, as the modules that declare them document them: [Fragment](/docs/develop/reference/jsx-runtime/#type-Fragment), [JSX](/docs/develop/reference/jsx-runtime/#type-JSX).

### jsxDEV

The JSX factory of a development build: `jsx`, with what such a build
adds about where the element was written left aside.

```ts
export declare function jsxDEV(type: unknown, props: Record<string, unknown> | null, key?: string | number): UiElement;
```

| Parameter | Type | Description |
|---|---|---|
| `type` | `unknown` | The component. |
| `props` | `Record<string, unknown> \| null` | Its props, `children` among them. |
| `key?` | `string \| number` | Its JSX `key`. |

Returns `UiElement`.

Example:

```ts
import { jsxDEV } from 'songstress/ui/jsx-dev-runtime'
import { Text } from 'songstress/ui'

const title = jsxDEV(Text, { children: 'Played lately' })
```

Refers to [UiElement](/docs/develop/reference/ui/#type-UiElement).
