Lewati ke konten utama
menjadi.dev
Backend

Hono

Web framework untuk edge computing — lightweight, cepat, dan modern.

Hono adalah web framework JavaScript/TypeScript yang lightweight dan ultra-fast, didesain untuk edge computing (Cloudflare Workers, Deno Deploy, Vercel Edge, Bun). Hono means ‘flame’ in Japanese. Fitur: Middleware support, TypeScript-first, multiple platform (Bun, Deno, Node.js, Edge), built-in validators, JWT helper, dan JSX support. Hono disebut ‘The small, simple, and ultrafast web framework’ — performanya mendekati native. Routing: app.get(), app.post(), app.use() untuk middleware. Hono mirip Express.js tapi lebih modern dan cepat.

Contoh Kode

import { Hono } from 'hono';

const app = new Hono();

// Middleware
app.use('*', logger(), cors(), prettyJSON());

// Routes
app.get('/', (c) => c.text('Hello Hono!'));
app.get('/users/:id', (c) => {
  const id = c.req.param('id');
  return c.json({ id, name: 'Budi' });
});

app.post('/users', async (c) => {
  const body = await c.req.json();
  // ...
  return c.json({ created: true }, 201);
});

export default app;

Istilah Terkait