Che cos'è tRPC?
Scopra tRPC, il suo scopo e come semplifica lo sviluppo di API sfruttando TypeScript.
Che cos'è tRPC? è una lezione tRPC End-to-End Type Safe APIs gratuita su CoddyKit. Questa è la lezione 1 di 4. Puoi leggere la lezione completa qui gratuitamente — poi esercitati direttamente nel browser con un editor di codice integrato e un tutor IA disponibile 24/7. Fa parte del percorso di apprendimento tRPC End-to-End Type Safe APIs, e i tuoi progressi si sincronizzano tra il web e l'app CoddyKit. Il corso tRPC End-to-End Type Safe APIs include 4 lezioni in totale.
Parti di questa lezione non sono ancora state tradotte e vengono mostrate in inglese.
Hello, tRPC!
Welcome to tRPC! APIs let separate systems talk — like a restaurant menu telling you what you can order and what to expect back.
Traditional API Challenges
Traditional REST and GraphQL share pain points: manual type syncing between client and server, boilerplate, and mismatches that only surface at runtime.
Meet tRPC: A New Approach
tRPC (TypeScript Remote Procedure Call) fixes that: end-to-end type-safe APIs with no schemas and no code generation. Fewer bugs, faster shipping.
The 'T' in tRPC: TypeScript
The T is TypeScript. tRPC uses its inference to auto-share types between backend and frontend — define the API once, the client just knows the shapes.
The 'RPC' in tRPC: Remote Calls
The RPC is Remote Procedure Call: invoke a server function as if it were local. tRPC makes backend procedures feel like plain imports on the frontend.
No Code Generation Needed
Unlike OpenAPI or GraphQL, tRPC needs no code generation. It shares types natively across your monorepo — less setup, fewer build steps, less to maintain.
Why Choose tRPC?
Why developers reach for tRPC: compile-time type safety, autocomplete-rich DX, zero codegen, and a lightweight client that ships only type definitions.
Server-Side Glimpse: A Query
On the server, an endpoint is a procedure. Here's a simple hello query that returns a message.
import { initTRPC } from '@trpc/server';
const t = initTRPC.create();
export const appRouter = t.router({
hello: t.procedure
.query(() => {
return { message: 'Hello from tRPC server!' };
}),
});
export type AppRouter = typeof appRouter;Client-Side Glimpse: Calling It
On the client, calling that procedure feels like a local function — with full type safety and autocomplete baked in.
import { createTRPCProxyClient, httpBatchLink } from '@trpc/client';
import type { AppRouter } from '../server/trpc'; // Type import
const trpc = createTRPCProxyClient<AppRouter>({
links: [
httpBatchLink({
url: 'http://localhost:3000/trpc',
}),
],
});
async function greet() {
const response = await trpc.hello.query();
console.log(response.message); // Type-safe access!
}
greet();Boost Your Developer Experience!
With tRPC you get instant autocomplete for every endpoint, input, and output. Rename a server field and TypeScript flags the breakage in your client at once.
Quick Check: What is tRPC?
Let's test your understanding of tRPC's core principles.
Recap: What is tRPC?
Recap: tRPC uses TypeScript for end-to-end type safety, the RPC model for direct calls, and zero codegen — all boosting developer experience. Next: type safety itself.
Domande Frequenti
La lezione «Che cos'è tRPC?» è gratuita?
Sì — il testo completo di «Che cos'è tRPC?» è gratuito qui sul web. Per esercitarvi in modo interattivo (un editor di codice integrato e un tutor IA 24/7) e sbloccare il resto del corso tRPC End-to-End Type Safe APIs, passa a CoddyKit PRO. Il corso tRPC End-to-End Type Safe APIs include 4 lezioni in totale.
Cosa imparerò in «Che cos'è tRPC?»?
Scopra tRPC, il suo scopo e come semplifica lo sviluppo di API sfruttando TypeScript. Eserciti tRPC End-to-End Type Safe APIs con codice pratico che esegui direttamente nel browser, e un tutor IA 24/7 risponde alle tue domande mentre lavori sulla lezione.
Ho bisogno di esperienza per iniziare tRPC End-to-End Type Safe APIs?
Non è richiesta alcuna esperienza precedente. tRPC End-to-End Type Safe APIs su CoddyKit è strutturato per principianti e studenti avanzati, quindi puoi iniziare da qui o dall'inizio e procedere al tuo ritmo. Questa è la lezione 1 di 4.
Quanto tempo richiede la lezione «Che cos'è tRPC?»?
La maggior parte delle lezioni CoddyKit richiede circa 5–10 minuti. Ogni lezione è breve e interattiva, quindi fai progressi costanti e riprendi esattamente da dove hai lasciato su web e app.
Posso scrivere ed eseguire codice in questa lezione tRPC End-to-End Type Safe APIs?
Sì. Ogni lezione tRPC End-to-End Type Safe APIs include un editor di codice integrato, quindi scrivi ed esegui codice reale direttamente nel tuo browser e ricevi feedback istantaneo dall'IA — nessuna configurazione locale necessaria.
Tutte le lezioni di questo corso
- Che cos'è tRPC?
- Il potere della type safety
- Panoramica dei concetti fondamentali di tRPC
- Configurare il primo progetto tRPC