oRPC Optimize SSR
Installation
SKILL.md
Optimize Server-Side Rendering (SSR) for Fullstack Frameworks
Optimize SSR with oRPC to eliminate redundant network calls during server rendering.
The Problem
Standard SSR involves the server making HTTP requests back to its own API endpoints, adding latency.
Conceptual approach
// Use this for server-side calls
const orpc = createRouterClient(router)
// Fallback to this for client-side calls
const orpc: RouterClient<typeof router> = createORPCClient(someLink)
A naive typeof window === 'undefined' check exposes your router logic to the client. Use globalThis to share the server client without bundling into client code.