Skip to content

How to run Hono JSX files in Hono? #2913

Closed Answered by fzn0x
fzn0x asked this question in Q&A
Discussion options

You must be logged in to vote

You can simply run the .tsx file to run the server with JSX. It also helps developers in VSCode to enable the React syntax. (don't forget to change your VSCode language mode to TypeScript React)

(package.json)

  "scripts": {
    "dev": "bun run --watch ./src/index.tsx",
// index.tsx
import type { PropsWithChildren } from "hono/jsx";
import { Hono } from "hono";

const app = new Hono();

type FileManager = {
  title: string;
  paths?: string[];
};

function FileManager({ title, children }: PropsWithChildren<FileManager>) {
  return (
    <div>
      <h1>{title}</h1>
      {children}
    </div>
  );
}
app.get("/static", (c) => {
  return c.html(<FileManager title="File Manager" />);
});

Goo…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by fzn0x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant