Silgi
Integrations

Hono

Use Silgi with Hono on any runtime — Node.js, Bun, Deno, Cloudflare Workers.

Hono is a fast web framework that runs everywhere. Silgi's Hono adapter mounts your procedures as a Hono handler.

Setup

import {  } from 'hono'
import {  } from 'silgi/hono'

const  = new ()

// Existing routes
.('/api/health', () => .({ : 'ok' }))

// Silgi RPC
.(
  '/rpc/*',
  (appRouter, {
    : () => ({
      : getDB(),
      : .get('user'),
    }),
  }),
)

export default 

Context from Hono

The context function receives Hono's Context object. Access middleware data via c.get():

silgiHono(appRouter, {
  : () => ({
    : .get('user'), // from Hono middleware
    : .get('requestId'),
    : .env, // Cloudflare Workers bindings
  }),
})

Cloudflare Workers

import {  } from 'hono'
import {  } from 'silgi/hono'

const  = new ()
.(
  '/rpc/*',
  (appRouter, {
    : () => ({ : .env.DB }),
  }),
)

export default 

What's next?

  • Server — standalone serve() as an alternative
  • Integrations — other available integrations

On this page