Silgi

Astro

Use Silgi with Astro API routes.

Astro supports server-side API routes via file-based routing. Silgi integrates via a catch-all endpoint.

Setup

Create a catch-all API route:

// src/pages/api/[...path].ts
import {  } from 'silgi/astro'
import {  } from '~/server/rpc'

const  = (, {
  : () => ({
    : getDB(),
    : .(.request.headers),
  }),
})

export const  = 
export const  = 

Procedures are accessible at:

POST /api/users/list
POST /api/users/create
GET  /api/health

SSR mode

Silgi requires server-side rendering. Enable it in your Astro config:

// astro.config.mjs
export default defineConfig({
  : 'server',
})

Analytics and Scalar

Enable the built-in analytics dashboard or Scalar API reference directly in the adapter:

const  = createHandler(appRouter, {
  : () => ({ : .(.request.headers) }),
  : {
    : process.env.ANALYTICS_TOKEN,
  },
  : true,
})

What's next?

  • Analytics — built-in monitoring dashboard
  • Server — standalone serve() as an alternative
  • Integrations — other available integrations

On this page