Skip to content

Hono

To use Hono as the main provider with Nixle, you need to install the @nixle/hono package. This package provides the necessary functionality for integrating Hono into your Nixle application.

Install

You can install the @nixle/hono package using npm, pnpm, yarn, or bun:

sh
npm i @nixle/hono
sh
pnpm add @nixle/hono
sh
yarn add @nixle/hono
sh
bun i @nixle/hono

Setup

ts
import { Hono } from 'hono';
import { serve } from '@hono/node-server';
import { createApp, createRouter } from 'nixle';
import { honoProvider } from '@nixle/hono';

const usersRouter = createRouter('/users', ({ route }) => [
  route.get('/', () => 'Hello Hono!'),
]);

const { app } = createApp({
  provider: honoProvider(new Hono()),
  routers: [usersRouter],
});

serve(app, (info) => {
  console.log(`Listening on http://localhost:${info.port}`);
});

Example