Preact rendering for Mage apps.
deno add jsr:@mage/app jsr:@mage/preact npm:preact
Minimal compilerOptions
:
{
"compilerOptions": {
"jsx": "react-jsx",
"jsxImportSource": "preact"
}
}
An example app:
import { MageApp } from "@mage/app";
import { render } from "@mage/preact";
const app = new MageApp();
app.get("/", async (c) => {
await render(
c,
<html lang="en">
<head>
<title>Hello, world!</title>
</head>
<body>
<h1>Hello, world!</h1>
</body>
</html>,
);
});
Deno.serve(app.handler);
Run the app:
deno run --allow-all main.ts