I showed you how to use Hono with Bun.
You can also use Node.js.
During the installation process of bunx create-hono <app-name>
, pick the nodejs
template:
Then go in that folder and install the dependencies with npm i
.
Open the src/index.ts
file in VS Code.
Compared to Bun, you see we need to import serve
from @hono/node-server
, and call it at the end, while with Bun you just have to export app
and Bun takes care of everything:
import { serve } from '@hono/node-server'
import { Hono } from 'hono'
const app = new Hono()
app.get('/', (c) => c.text('Hello Hono!'))
serve(app)
Now run npm run start
in your terminal to run Hono.
Lessons in this unit:
0: | Introduction |
1: | Your first Hono app |
2: | The Request object |
3: | Send a response to the client |
4: | Manage cookies |
5: | Work with HTTP headers |
6: | Handling redirects |
7: | Routing |
8: | JSX templates |
9: | Middleware |
10: | ▶︎ Hono on Node.js |