Skip to main content

Command Palette

Search for a command to run...

FrameWork Modern With "Hono" , Could Compete with Express.js or Next.js ?: Node.js

By Ahmad Afan Shobari

Updated
2 min read
FrameWork Modern With "Hono" , Could Compete with Express.js or Next.js ?: Node.js
A
I'm a Programmer

Assalamualaikum,hello everybody i hope you all healthy, so in this article we learn about hono, hono is framework which use for node.js, why use hono? because hono is very fast, api simple and modern, function small backend, and other.

1. Install Hono From Node.JS

first, we will install hono in the we directory.

!! remember, make sure you install in diretory the true !!

than we can do init

after init, we can add new line in package.json(add esm),

"type":"module"

than install hono with this code

npm i hono

enough, you success install hono on your directory

2. Testing with Hono

Second, we will test hono can progress or not ?
than install server hono with this code:

npm i @hono/node-server

we will create new file name is Server.js and add this code

import { Hono } from "hono";
import { serve } from "@hono/node-server";

const app = new Hono();

app.get("/", (c) => {
    return c.html(`
<h1> sample doc API</h1>
<p>rute available</p>
<ul>
<li><a href="/text"> - discribe text biasa</li>
<li><a href="/json"> - discribe output json</li>
</ul>
`)
}
);

app.get("/text", (c) => c.text("hallo this a normal text"));

app.get("/json", (c) => c.json({ data: "this response for JSON", Status: "ok" }));

serve(app, (info) => {
    console.log(`yes, you can do this http://localhost:${info.port}`)
})

and this result run the server.js

3. Error

honest i have many error because i am a newbie and noob.

and i forgot to screen shot my desktop, i am sorry.

4. Closing

thanks for your watching , and see you next time

sorry i can’t speak english but i hope can in future

FrameWork Modern With "Hono" , Could Compete with Express.js or Next.js ?: Node.js