[](https://npmjs.com/package/h3)
[](https://npmjs.com/package/h3)
[](https://bundlephobia.com/result?p=h3)
[](https://github.com/unjs/h3/actions)
[](https://codecov.io/gh/unjs/h3)
[](https://www.jsdocs.io/package/h3)
> H3 is a minimal h(ttp) framework built for high performance and portability
## Features
✔️ **Portable:** Works perfectly in Serverless, Workers, and Node.js
✔️ **Minimal:** Small and tree-shakable
✔️ **Modern:** Native promise support
✔️ **Extendable:** Ships with a set of composable utilities but can be extended
✔️ **Router:** Super fast route matching using [unjs/radix3](https://github.com/unjs/radix3)
✔️ **Compatible:** Compatibility layer with node/connect/express middleware
## Install
```bash
# Using npm
npm install h3
# Using yarn
yarn add h3
# Using pnpm
pnpm add h3
```
## Usage
```ts
import { createServer } from 'http'
import { createApp, eventHandler, toNodeListener } from 'h3'
const app = createApp()
app.use('/', eventHandler(() => 'Hello world!'))
createServer(toNodeListener(app)).listen(process.env.PORT || 3000)
```
Example using listhen for an elegant listener.
```ts
import { createApp, toNodeListener } from 'h3'
import { listen } from 'listhen'
const app = createApp()
app.use('/', eventHandler(() => 'Hello world!'))
listen(toNodeListener(app))
```
## Router
The `app` instance created by `h3` uses a middleware stack (see [how it works](#how-it-works)) with the ability to match route prefix and apply matched middleware.
To opt-in using a more advanced and convenient routing system, we can create a router instance and register it to app instance.
```ts
import { createApp, eventHandler, createRouter } from 'h3'
const app = createApp()
const router = createRouter()
.get('/', eventHandler(() => 'Hello World!'))
.get('/hello/:name', eventHandler(event => `Hello ${event.context.params.name}!`))
app.use(router)
```
**Tip:** We can register same route more than once with different methods.
Routes are internally stored in a [Radix Tree](https://en.wikipedia.org/wiki/Radix_tree) and matched using [unjs/radix3](https://github.com/unjs/radix3).
## More app usage examples
```js
// Handle can directly return object or Promise