Skip to content

Using hono

Course: Serverless Backends - chapter 10

https://hono.dev/concepts/motivation

  1. Initialize a new app
Terminal window
npm create hono@latest my-app
  1. Move to my-app and install the dependencies.
Terminal window
cd my-app
npm i
  1. Hello World
import { Hono } from 'hono'
const app = new Hono()
app.get('/', (c) => c.text('Hello Cloudflare Workers!'))
export default app
import { Hono } from 'hono'
const app = new Hono()
app.get('/', async (c) => {
const body = await c.req.json()
console.log(body);
console.log(c.req.header("Authorization"));
console.log(c.req.query("param"));
return c.text('Hello Hono!')
})
export default app

💡 More detail - https://hono.dev/getting-started/cloudflare-workers

Make sure you’re logged into cloudflare (wrangler login)

npm run deploy