Tech TutorBangla Web Documentation
Portfolio
HomeHTMLCSSTailwind CSSJavaScriptTypeScriptReactNext.jsNode.jsExpressSocket.IOExpoWordPressPostgreSQLPrismaPostgresNestJSMongoDBDockerTanStackTanStack TableRTK QueryGitGitHub
  • PrismaPostgres Documentation40টি অধ্যায়
প্রযুক্তি নির্বাচন
HomeHTMLCSSTailwind CSSJavaScriptTypeScriptReactNext.jsNode.jsExpressSocket.IOExpoWordPressPostgreSQLPrismaPostgresNestJSMongoDBDockerTanStackTanStack TableRTK QueryGitGitHub
  • Prisma Intro
  • Prisma vs Raw SQL
  • Setup & Install
  • Schema Basics
  • Models
  • Relations
  • Migrations
  • Prisma Client
  • Create & Upsert
  • Read Queries
  • Update & Delete
  • Query Filters
  • Sort & Pagination
  • Select & Include
  • Nested Writes
  • Transactions
  • Aggregation
  • JSON Fields
  • Raw SQL
  • TechShop Schema
  • TechShop Seed
  • Relations Advanced
  • Env Config
  • Global Client
  • Next.js + Prisma
  • Express API
  • Error Handling
  • Performance
  • Connection Pool
  • Prisma Studio
  • Deploy Migrations
  • TechShop Indexes
  • TechShop Cart
  • TechShop Stats API
  • Schema Evolution
  • Debugging
  • Common Mistakes
  • Best Practices
  • Interview Questions
  • Recap & Next
  1. Docs
  2. PrismaPostgres
  3. Server Components & Route Handlers
PrismaPostgresAdvanced

Server Components & Route Handlers

Next.js 14/15-এ Prisma — server-সাইড data fetch ও API।

4টি অংশবাংলা ভাষায়
server component (page.tsx)tsx
tsx
import { prisma } from "@/lib/prisma";

export default async function ProductsPage() {
  const products = await prisma.product.findMany({
    where: { active: true },
    orderBy: { price: "desc" },
    take: 12,
  });

  return (
    <main>
      {products.map((p) => (
        <div key={p.id}>
          <h2>{p.name}</h2>
          <p>{p.price} TK</p>
        </div>
      ))}
    </main>
  );
}
route handler (app/api/products/route.ts)ts
ts
import { NextResponse } from "next/server";
import { prisma } from "@/lib/prisma";

export async function GET() {
  const products = await prisma.product.findMany();
  return NextResponse.json({ products });
}
  • Server Component-এ query — client-এ network নয়
  • Route handler — API/json
  • cache opt-in — data যতবার বদলায় (revalidate)
সতর্ক

মনে রাখুন — use client-চিহ্নিত ফাইলে Prisma query চলে না; সব query Server Components/API-তে। এজ-runtime-এ Prisma full-connection দরকার (node runtime)।

শেষ প্যারায় নিজে practice করুন — কোড কপি করে নিজের এডিটরে চালিয়ে দেখুন।
আগেরSingleton — hot-reload-এ এক PrismaClientপরেরExpress + Prisma — TechShop API
Tech Tutor

বাংলায় ওয়েব ডেভেলপমেন্ট ডকুমেন্টেশন শিখুন — ধাপে ধাপে।

Homeসব ডকুমেন্টেশনQuick Startআমার নোটস

© 2026 Tech Tutor. বাংলায় শিখুন, বাংলায় গড়ুন।

mdanamolhasan1998@gmail.com