Skip to content
Discussion options

You must be logged in to vote

Yes, you are not limited to JSX — Hono supports returning raw HTML strings directly.

Option 1: Return HTML strings with c.html()

app.get("/", (c) => {
  return c.html("<h1>Hello World</h1><p>No JSX needed</p>");
});

Option 2: Read and serve HTML files

import { readFile } from "fs/promises";

app.get("/page", async (c) => {
  const html = await readFile("./views/page.html", "utf-8");
  return c.html(html);
});

Option 3: Use a template engine

You can plug in any template engine (ETA, Mustache, etc.):

import { Eta } from "eta";
const eta = new Eta({ views: "./views" });

app.get("/", (c) => {
  const html = eta.render("index", { name: "World" });
  return c.html(html);
});

For Svelte specifi…

Replies: 1 comment

Comment options

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