A Little About Hono

What’s Hono?
Hono is a small and fast web framework for building APIs and web apps in JavaScript and TypeScript. It is lightweight, modern, and works across different runtimes like Node.js, Bun, and Deno.
_____________________________________________________________________________________________________
Let’s Try With Me !!
_____________________________________________________________________________________________________
Setup
Open Git Bash and go to your project folder.

initialize npm.

open package.json with nano and add ‘ ”type” : “module”, ‘ inside. This makes npm work with Hono or other modules that use ES modules.

Use nano to edit a file, or create one if it doesn’t exist.

and install hono.

and don’t forget from install @hono/node-server.

if you don’t install this, you will get an error when running the file later, like this

_____________________________________________________________________________________________________
Create File
create a file named
service.js(you can use nano or any editor)
_____________________________________________________________________________________________________
Run the server
write this code inside file server.js

Save and exit with Ctrl + X, then press Y, then Enter.
Run the code with
node server.js
_____________________________________________________________________________________________________
Routes Result
Open
http://localhost:3000/→ you will see the main page.
Open
http://localhost:3000/text→ you will see the text response, or click /text in main page
Open
http://localhost:3000/json→ you will see the JSON response, or click /json in main page
_____________________________________________________________________________________________________
Closing
And that’s it! 🎉
Now you’ve got a simple Hono server running.
Later you can try middleware, auth, or even deploy it.
Thanks for reading! Stay tuned on my blog for more articles or the next episode.
_____________________________________________________________________________________________________
note: picture from https://dev.to/joodi/honojs-a-lightweight-framework-with-big-potential-3lh9



