diff --git a/examples/hono-jsx-ts/.gitignore b/examples/hono-jsx-ts/.gitignore new file mode 100644 index 0000000000..f86f576435 --- /dev/null +++ b/examples/hono-jsx-ts/.gitignore @@ -0,0 +1,34 @@ +# prod +dist/ + +# dev +.hono/ +.wrangler/ +.yarn/ +!.yarn/releases +.vscode/* +!.vscode/launch.json +!.vscode/*.code-snippets +.idea/workspace.xml +.idea/usage.statistics.xml +.idea/shelf + +# deps +node_modules/ + +# env +.env +.env.production +.dev.vars + +# logs +logs/ +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + +# misc +.DS_Store diff --git a/examples/hono-jsx-ts/app/client.ts b/examples/hono-jsx-ts/app/client.ts new file mode 100644 index 0000000000..5021a92e21 --- /dev/null +++ b/examples/hono-jsx-ts/app/client.ts @@ -0,0 +1,3 @@ +import { createClient } from "honox/client" + +createClient() diff --git a/examples/hono-jsx-ts/app/global.d.ts b/examples/hono-jsx-ts/app/global.d.ts new file mode 100644 index 0000000000..41912351e3 --- /dev/null +++ b/examples/hono-jsx-ts/app/global.d.ts @@ -0,0 +1,8 @@ +import type {} from "hono" + +declare module "hono" { + interface Env { + Variables: {} + Bindings: {} + } +} diff --git a/examples/hono-jsx-ts/app/islands/counter.tsx b/examples/hono-jsx-ts/app/islands/counter.tsx new file mode 100644 index 0000000000..e6b9325d73 --- /dev/null +++ b/examples/hono-jsx-ts/app/islands/counter.tsx @@ -0,0 +1,13 @@ +import { useState } from "hono/jsx" + +export default function Counter() { + const [count, setCount] = useState(0) + return ( +
+

{count}

+ +
+ ) +} diff --git a/examples/hono-jsx-ts/app/routes/_404.tsx b/examples/hono-jsx-ts/app/routes/_404.tsx new file mode 100644 index 0000000000..1c12d8df33 --- /dev/null +++ b/examples/hono-jsx-ts/app/routes/_404.tsx @@ -0,0 +1,8 @@ +import type { NotFoundHandler } from "hono" + +const handler: NotFoundHandler = (c) => { + c.status(404) + return c.render("404 Not Found") +} + +export default handler diff --git a/examples/hono-jsx-ts/app/routes/_error.tsx b/examples/hono-jsx-ts/app/routes/_error.tsx new file mode 100644 index 0000000000..121e07f121 --- /dev/null +++ b/examples/hono-jsx-ts/app/routes/_error.tsx @@ -0,0 +1,12 @@ +import type { ErrorHandler } from "hono" + +const handler: ErrorHandler = (e, c) => { + if ("getResponse" in e) { + return e.getResponse() + } + console.error(e.message) + c.status(500) + return c.render("Internal Server Error") +} + +export default handler diff --git a/examples/hono-jsx-ts/app/routes/_renderer.tsx b/examples/hono-jsx-ts/app/routes/_renderer.tsx new file mode 100644 index 0000000000..33946865a1 --- /dev/null +++ b/examples/hono-jsx-ts/app/routes/_renderer.tsx @@ -0,0 +1,17 @@ +import { jsxRenderer } from "hono/jsx-renderer" +import { Link, Script } from "honox/server" + +export default jsxRenderer(({ children }) => { + return ( + + + + + + +