Skip to content

Commit dcbb41a

Browse files
committed
Use hono to render jsx
1 parent 27ad42d commit dcbb41a

File tree

6 files changed

+39
-27
lines changed

6 files changed

+39
-27
lines changed

app/worker.ts

Lines changed: 0 additions & 24 deletions
This file was deleted.

app/worker.tsx

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { Hono } from "hono";
2+
3+
const app = new Hono();
4+
5+
// Root route
6+
app.get("/", (c) => {
7+
return c.html(
8+
<html>
9+
<body>
10+
<h1>Hello World</h1>
11+
</body>
12+
</html>
13+
);
14+
});
15+
16+
// Default route - return 404 for any other path
17+
app.all("*", (c) => {
18+
return c.html(
19+
<html>
20+
<body>
21+
<h1>404 - Not Found</h1>
22+
<p>The requested page does not exist.</p>
23+
</body>
24+
</html>,
25+
404
26+
);
27+
});
28+
29+
export default {
30+
fetch: app.fetch,
31+
};

bun.lock

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"name": "models.dev",
66
"dependencies": {
77
"@iarna/toml": "^2.2.5",
8+
"hono": "^4.7.11",
89
"sst": "^3.17.3",
910
"zod": "^3.25.51",
1011
},
@@ -117,7 +118,7 @@
117118

118119
"hasown": ["[email protected]", "", { "dependencies": { "function-bind": "^1.1.2" } }, "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ=="],
119120

120-
"hono": ["[email protected].4", "", {}, "sha512-Pst8FuGqz3L7tFF+u9Pu70eI0xa5S3LPUmrNd5Jm8nTHze9FxLTK9Kaj5g/k4UcwuJSXTP65SyHOPLrffpcAJg=="],
121+
"hono": ["[email protected].11", "", {}, "sha512-rv0JMwC0KALbbmwJDEnxvQCeJh+xbS3KEWW5PC9cMJ08Ur9xgatI0HmtgYZfOdOSOeYsp5LO2cOhdI8cLEbDEQ=="],
121122

122123
"http-errors": ["[email protected]", "", { "dependencies": { "depd": "2.0.0", "inherits": "2.0.4", "setprototypeof": "1.2.0", "statuses": "2.0.1", "toidentifier": "1.0.1" } }, "sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ=="],
123124

@@ -277,6 +278,8 @@
277278

278279
"zod-to-json-schema": ["[email protected]", "", { "peerDependencies": { "zod": "^3.24.1" } }, "sha512-HIAfWdYIt1sssHfYZFCXp4rU1w2r8hVVXYIlmoa0r0gABLs5di3RCqPU5DDROogVz1pAdYBaz7HK5n9pSUNs3A=="],
279280

281+
"opencontrol/hono": ["[email protected]", "", {}, "sha512-Pst8FuGqz3L7tFF+u9Pu70eI0xa5S3LPUmrNd5Jm8nTHze9FxLTK9Kaj5g/k4UcwuJSXTP65SyHOPLrffpcAJg=="],
282+
280283
"opencontrol/zod": ["[email protected]", "", {}, "sha512-lY7CDW43ECgW9u1TcT3IoXHflywfVqDYze4waEz812jR/bZ8FHDsl7pFQoSZTz5N+2NqRXs8GBwnAwo3ZNxqhQ=="],
281284

282285
"openid-client/jose": ["[email protected]", "", {}, "sha512-1vUQX+IdDMVPj4k8kOxgUqlcK518yluMuGZwqlr44FS1ppZB/5GWh4rZG89erpOBOJjU/OBsnCVFfapsRz6nEA=="],

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
},
1212
"dependencies": {
1313
"@iarna/toml": "^2.2.5",
14+
"hono": "^4.7.11",
1415
"sst": "^3.17.3",
1516
"zod": "^3.25.51"
1617
}

sst.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export default $config({
1010
async run() {
1111
new sst.cloudflare.Worker("MyWorker", {
1212
domain: "models.dev",
13-
handler: "app/worker.ts",
13+
handler: "app/worker.tsx",
1414
url: true,
1515
assets: {
1616
directory: "./dist",

tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
{
22
"compilerOptions": {
33
// Environment setup & latest features
4-
"lib": ["ESNext"],
4+
"lib": ["ESNext", "DOM"],
55
"target": "ESNext",
66
"module": "ESNext",
77
"moduleDetection": "force",
88
"jsx": "react-jsx",
9+
"jsxImportSource": "hono/jsx",
910
"allowJs": true,
1011

1112
// Bundler mode

0 commit comments

Comments
 (0)