Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions getting-started/nodejs.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,28 @@ serve({
})
```

## Access the raw Node.js APIs

You can access the Node.js APIs from `c.env.incoming` and `c.env.outgoing`.

```ts
import { Hono } from 'hono'
import { serve, type HttpBindings } from '@hono/node-server'
// or `Http2Bindings` if you use HTTP2

type Bindings = HttpBindings & {/* ... */}

const app = new Hono<{ Bindings: Bindings }>()

app.get('/', (c) => {
return c.json({
remoteAddress: c.env.incoming.socket.remoteAddress,
})
})

serve(app)
```

## Serve static files

You can use `serveStatic` to serve static files from the local file system.
Expand Down