# API With Hono For You Javascript Project

Assalamualaikum, Hello everyone i hope you good today, so i’ll explain you about Hono (similiar with next.js).

# What is Hono?

Hono is framework to many language programming, is simple, fast, and easy, hono in web dev it is mean **backend developer**.

backend developer is programmer who menages data and server for website

# How To Use Hono In Javascript

First, initialization npm in your project

```powershell
npm init
```

then change type on package.json to “module”

next install hono with npm, yarn, or other ways.

```powershell
npm install hono @hono/node-server
```

then create file server.js and this code

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

const app = new Hono();

app.get("/", (c) => {
    return c.html(`
        <h1>Hallo Hono</h1>
        <p>Rute yang tersedia:</p>
        <ul>
        <li><a href="/text">/text</a> - Menampilka Text biasa</li>

        <li><a href="/json">/json</a> - Menampilkan Output JSON</li>
        </ul>`);
});

// Rute untuk Text
app.get("/text", (c) => c.text("ini adalah respons text biasa"));

// Rute untuk JSON
app.get("/json", (c) => c.json({data : "Hello Santri.", status: "ok"}));

serve({fetch: app.fetch, port:3100}, (info) => {
    console.log(`server berjalan di http://localhost:${info.port}`);
});
```

so now you can running the code

```powershell
node server.js
```

so this is result

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1768275405849/4f16f4d1-5b5c-48d0-93d5-5bdfe3bca927.png align="center")

# How Try API

you can use postman, echo api, etc, for example i use echo api here.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1768275984655/bc9f27d4-e966-42cf-a062-9ccbcbfe0d9c.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1768276005321/eb52d9d1-ba69-4f09-98e3-6d045b1922a9.png align="center")

and success…..

# Closing

thanks for watching, see you next video…..
