server-side-calls

Call tRPC procedures directly from server-side Node.js code.

2|Updated Apr 11, 2026
One-click install
npx skills add https://github.com/PlazaCC/antes-da-tela --skill server-side-calls
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: server-side-calls
Source: https://github.com/PlazaCC/antes-da-tela/tree/main/.agents/skills/server-side-calls
Command: npx skills add https://github.com/PlazaCC/antes-da-tela --skill server-side-calls

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This guide explains how to invoke tRPC procedures directly from server code to run integration tests, implement internal server logic, and expose server-only API endpoints without an HTTP layer.

Core Features & Use Cases

  • Direct caller creation: Use createCallerFactory or router.createCaller to invoke procedures with a fully-formed server context.
  • Integration testing: Execute procedures in tests with simulated contexts to validate behavior without running an HTTP server.
  • Error handling for APIs: Catch TRPCError and map it to HTTP status codes using getHTTPStatusCodeFromError and optionally observe errors with onError callbacks.
  • Best practices: Avoid creating callers inside procedures; extract shared logic into plain functions and supply proper context when calling protected routes.

Quick Start

Create a caller with createCallerFactory using a test context that includes a simulated user and call post.list to retrieve posts.

Frequently Asked Questions about server-side-calls

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I call tRPC procedures directly from server code without an HTTP layer?▼

To call tRPC procedures directly from server code, use createCallerFactory or router.createCaller to invoke procedures with a fully-formed server context, bypassing the HTTP layer for internal operations.

How do I run integration tests for tRPC procedures without starting an HTTP server?▼

You can run integration tests by creating a caller with createCallerFactory and passing a simulated test context that includes mock user data, allowing you to validate procedure behavior without an HTTP server.

How do I handle TRPCError and map it to HTTP status codes in custom API endpoints?▼

Handle TRPCError in custom API endpoints by catching the error and mapping it to HTTP status codes using getHTTPStatusCodeFromError, while optionally observing error details through onError callbacks.

Can I use server-side tRPC callers to power custom API endpoints?▼

Yes, server-side tRPC callers can power custom API endpoints by invoking procedures directly with proper context objects, enabling server-only logic without relying on standard HTTP request routing.

What are the limitations of creating tRPC callers inside other procedures?▼

Creating tRPC callers inside other procedures is discouraged as a best practice; instead, extract shared logic into plain functions and supply proper context when calling protected routes to avoid context issues.

Do I need to provide a matching context object when calling protected tRPC routes server-side?▼

Yes, you must provide a matching context object containing necessary authentication data when using server-side tRPC callers to invoke protected routes, ensuring the procedure has the required permissions.