tRPC End-to-End Type Safe APIs · درس

ما هي tRPC؟

تعرّفوا على tRPC وهدفها وكيف تبسّط تطوير API بالاستفادة من TypeScript.

الدرس 1 من 412 خطوة

ما هي tRPC؟ درس مجاني في tRPC End-to-End Type Safe APIs على CoddyKit. هذا هو الدرس 1 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في tRPC End-to-End Type Safe APIs، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة tRPC End-to-End Type Safe APIs 4 دروس في المجموع.

بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.

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.

البدء مجانًا

تعلم tRPC End-to-End Type Safe APIs مع معلم ذكاء اصطناعي — مجانًا

اكتب وقم بتشغيل أكوادك الفعلية في المتصفح، واحصل على مساعدة فورية من معلم ذكاء اصطناعي متاح 24/7، واستمر من حيث توقفت على الويب أو في التطبيق.

الدورات
10
الدروس
40

الأسئلة الشائعة

هل درس «ما هي tRPC؟» مجاني؟

نعم — نص درس «ما هي tRPC؟» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة tRPC End-to-End Type Safe APIs، انتقل إلى CoddyKit PRO. تتضمن دورة tRPC End-to-End Type Safe APIs 4 دروس في المجموع.

ماذا ستتعلم في «ما هي tRPC؟»؟

تعرّفوا على tRPC وهدفها وكيف تبسّط تطوير API بالاستفادة من TypeScript. تتمرن على tRPC End-to-End Type Safe APIs مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.

هل أحتاج إلى خبرة سابقة لأبدأ tRPC End-to-End Type Safe APIs؟

لا تُشترط خبرة سابقة. tRPC End-to-End Type Safe APIs على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 1 من أصل 4.

كم من الوقت يستغرق درس «ما هي tRPC؟»؟

معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.

هل يمكنني كتابة وتشغيل أكواد في درس tRPC End-to-End Type Safe APIs هذا؟

نعم. كل درس في tRPC End-to-End Type Safe APIs يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.

جميع الدروس في هذه الدورة

  1. ما هي tRPC؟
  2. قوة أمان الأنواع
  3. نظرة عامة على مفاهيم tRPC الأساسية
  4. إعداد أول مشروع لك باستخدام tRPC
← العودة إلى tRPC End-to-End Type Safe APIs