JSX
How Nub runs JSX on stock Node — automatic-runtime defaults, tsconfig-driven configuration, and the per-file import-source pragma for mixing runtimes.
Files ending in .jsx and .tsx execute through the same load hook. JSX is recognized in .jsx / .tsx only, never in plain .js. The defaults are the modern ones — automatic runtime, react as the import source — matching oxc-transformer, Vite's React plugins, Rolldown, and Bun, so a React project needs no setup.
nub render.tsxnub.jsonc
Configure the runtime directly in the project file. The field names match TypeScript's compiler options, and the jsx field accepts the three modes that emit executable JavaScript: react, react-jsx, and react-jsxdev.
{
"jsx": "react-jsx",
"jsxImportSource": "preact"
}The classic runtime also accepts jsxFactory and jsxFragmentFactory.
{
"jsx": "react",
"jsxFactory": "h",
"jsxFragmentFactory": "Fragment"
}tsconfig.json
Nub still reads the same settings from compilerOptions when they are absent from nub.jsonc, so the runtime can share configuration with the rest of the toolchain. Top-level Nub fields win when both files set the same option.
| Option | Effect |
|---|---|
jsx | The runtime mode: preserve, react, react-jsx, react-jsxdev, or react-native |
jsxImportSource | The package the automatic runtime imports from, such as preact |
jsxFactory | The factory function for the classic runtime |
jsxFragmentFactory | The fragment factory for the classic runtime |
{
"compilerOptions": {
"jsx": "react-jsx",
"jsxImportSource": "preact"
}
}Read the full docs for jsx on typescriptlang.org.
Preact, Hono, and Vue JSX work via passthrough. Solid is the exception — its JSX needs babel-preset-solid's reactive-graph compilation, which a per-file transpiler can't do, so run Solid through its bundler (e.g. nub run vite).
@jsxImportSource
A per-file /** @jsxImportSource ... */ pragma overrides the tsconfig import source for that one file. This is the standard mechanism for mixing JSX runtimes in a single project — a Hono route alongside React components.
/** @jsxImportSource hono/jsx */
export default function Page() {
return <h1>Hello</h1>;
}The pragma is read from the file source itself; no tsconfig entry is needed for it to take effect.
TypeScript
How Nub runs every TypeScript feature on stock Node — non-erasable syntax, resource-management downleveling, and source maps — none of which plain Node does.
Decorators
How Nub runs legacy TypeScript decorators and their emitted design-type metadata on stock Node — the form the NestJS, TypeORM, and Angular dependency-injection ecosystem is written against.