TypeScript & JSX
Nebula uses Preact for its lightweight JSX runtime. Preact is bundled for runtime, but TypeScript still needs local types.
Install Preact (types)
Section titled “Install Preact (types)”npm install -D preacttsconfig.json
Section titled “tsconfig.json”{ "compilerOptions": { "jsx": "react-jsx", "jsxImportSource": "preact" }}Without JSX
Section titled “Without JSX”Use createElement or h from nebula-pdf-engine:
import { PdfEngine, Page, Text, createElement, h } from 'nebula-pdf-engine';
const tree = createElement( Page, { size: 'A4', padding: 40 }, h(Text, { style: { fontSize: 20 } }, 'Hello Workspace!'),);
const pdf = await engine.generate(tree);Typed tables
Section titled “Typed tables”ColumnDefinition<T> and TableProps<T> use key: keyof T:
type Row = { id: string; desc: string; amt: number };
const columns: ColumnDefinition<Row>[] = [ { header: 'ID', key: 'id', width: 50 }, { header: 'Description', key: 'desc', flex: 1 }, { header: 'Amount', key: 'amt', width: 80, align: 'right' },];