Integrations
Next.js
Use Silgi with Next.js App Router — API routes with full type safety and protocol support.
Silgi integrates with Next.js App Router via catch-all API routes. Full content negotiation (JSON, MessagePack, devalue) works out of the box.
Setup
Create a catch-all API route:
// app/api/rpc/[...path]/route.ts
import { } from 'silgi/nextjs'
import { } from '~/server/rpc'
const = (, {
: '/api/rpc',
: () => ({
: getDB(),
: .(.),
}),
})
export { as , as }Procedures are accessible at:
POST /api/rpc/users/list
POST /api/rpc/users/create
GET /api/rpc/healthServer Actions
For server-first React apps, use React Server Actions instead of API routes:
// app/actions.ts
'use server'
import { } from 'silgi/react'
export const = (appRouter.users.list)Edge Runtime
The handler uses standard Fetch API — works on both Node.js and Edge runtime:
export const = 'edge'Silgi compiles the router once at module load time. Next.js caches module imports across requests, so the compilation cost is paid only once per cold start.
What's next?
- React Server Actions —
[error, data]tuple pattern - TanStack Query — React Query integration
- Integrations — other available integrations