How to Monitor tRPC APIs with Vigilmon
tRPC lets you build end-to-end type-safe APIs without schemas or code generation. But it uses a non-standard HTTP interface that confuses traditional API monitors. This guide shows how to monitor tRPC APIs correctly with Vigilmon.
How tRPC Works (and Why Monitoring is Different)
tRPC procedures are called via HTTP GET (queries) or POST (mutations):
GET /api/trpc/user.getProfile?input={"userId":1} # query
POST /api/trpc/auth.login # mutation
Standard API monitors work fine with tRPC — you just need to know the URL format. The best approach is adding a dedicated health check procedure that Vigilmon can call without authentication.
Adding a tRPC Health Check Procedure
Create a health check procedure in your router:
// server/router/health.ts
import { router, publicProcedure } from '../trpc';
export const healthRouter = router({
check: publicProcedure.query(() => {
return {
status: 'ok' as const,
timestamp: new Date().toISOString(),
version: process.env.APP_VERSION ?? '1.0.0'
};
}),
});
Register it in your main router:
// server/router/index.ts
import { router } from '../trpc';
import { healthRouter } from './health';
export const appRouter = router({
health: healthRouter,
user: userRouter,
// ... other routers
});
Your health check is now available at:
GET /api/trpc/health.check
Response:
{
"result": {
"data": {
"status": "ok",
"timestamp": "2026-08-05T10:00:00.000Z"
}
}
}
Setting Up Vigilmon for tRPC
Monitor 1: tRPC Health Check Procedure
-
URL:
https://your-app.com/api/trpc/health.check - Method: GET
- Expected status: 200
-
Keyword check:
"status":"ok" - Interval: 60 seconds
- Multi-region: Enabled
Monitor 2: Main Application
Also monitor your Next.js/Remix root to catch framework-level issues:
-
URL:
https://your-app.com - Expected status: 200
- Interval: 120 seconds
Monitor 3: tRPC Batch Endpoint
If your clients use batching, verify it works:
-
URL:
https://your-app.com/api/trpc/health.check?batch=1&input={"0":{}} - Expected status: 200
tRPC with Next.js App Router
// app/api/trpc/[trpc]/route.ts
import { fetchRequestHandler } from '@trpc/server/adapters/fetch';
import { appRouter } from '@/server/router';
const handler = (req: Request) =>
fetchRequestHandler({
endpoint: '/api/trpc',
req,
router: appRouter,
createContext: () => ({}),
});
export { handler as GET, handler as POST };
Monitor URL: https://your-nextjs-app.com/api/trpc/health.check
tRPC with Express
import { createExpressMiddleware } from '@trpc/server/adapters/express';
import express from 'express';
const app = express();
app.use('/trpc', createExpressMiddleware({ router: appRouter }));
// Traditional health endpoint alongside tRPC
app.get('/health', (req, res) => {
res.json({ status: 'ok' });
});
app.listen(3000);
Monitor both /health AND /trpc/health.check for redundancy.
Alert Configuration
Configure Vigilmon alerts for your tRPC backend:
- Slack: #api-alerts channel
- Email: backend-team@yourcompany.com
- PagerDuty: For production APIs serving paying customers
Common tRPC Failure Modes
- Database disconnection: Procedures fail but health check (without DB check) still returns 200 — add DB connectivity check to your health procedure
- Middleware errors: Auth middleware throwing breaks all procedures — health check must bypass auth
- Cold starts on serverless: Vercel/Lambda cold starts add latency — set 10-second timeout in Vigilmon
- Type mismatch after deploy: Client/server type drift causes runtime errors visible as HTTP failures
Best Practices
- Create
health.checkas a public procedure with no authentication required - Include database connectivity in the health check response
- Use keyword checking — tRPC returns 200 even for procedure errors (errors are in the JSON body)
- Monitor both the tRPC endpoint AND a traditional
/healthroute - Check the batch endpoint if your clients use tRPC batching
Conclusion
tRPC type-safe API design is excellent for developer experience, and Vigilmon makes it straightforward to monitor with external HTTP checks, multi-region validation, and instant alerts.
Monitor your tRPC API free at vigilmon.online
Top comments (0)