Tech TutorBangla Web Documentation
Portfolio
HomeHTMLCSSTailwind CSSJavaScriptTypeScriptReactNext.jsNode.jsExpressSocket.IOExpoWordPressPostgreSQLPrismaPostgresNestJSMongoDBDockerTanStackTanStack TableRTK QueryGitGitHub
  • Next.js Documentation27টি অধ্যায়
প্রযুক্তি নির্বাচন
HomeHTMLCSSTailwind CSSJavaScriptTypeScriptReactNext.jsNode.jsExpressSocket.IOExpoWordPressPostgreSQLPrismaPostgresNestJSMongoDBDockerTanStackTanStack TableRTK QueryGitGitHub
  • Introduction
  • কেন Next.js?
  • Installation
  • Project Structure
  • Routing ও Pages
  • Layouts
  • Linking ও Navigation
  • Server & Client Components
  • Dynamic Routes
  • Data Fetching
  • Loading ও Streaming
  • Error Handling
  • Route Handlers
  • Server Actions
  • Caching ও Revalidation
  • Metadata ও SEO
  • Images ও Fonts
  • Styling
  • Environment Variables
  • Development ও Production
  • Deployment
  • Configuration
  • Static ও Dynamic Rendering
  • Proxy
  • Performance
  • Project: Blog
  • Project: Dashboard
  1. Docs
  2. Next.js
  3. Proxy (Former Middleware)
Next.jsAdvanced

Proxy (Former Middleware)

proxy.ts দিয়ে request-এই code চালানো — redirect, rewrite, auth বাংলায়।

10টি অংশবাংলা ভাষায়

Proxy (proxy.ts) হলো একটি file যা প্রতিটি request-এ server side চলে — request সম্পন্ন হওয়ার আগে। redirect, rewrite, authentication চেকের জন্য ব্যবহৃত হয়।

এটি আগে Middleware নামে পরিচিত ছিল। Next.js 16-এ এই নামে রেনাম হয়েছে।

প্রথম Proxy

proxy.tsts
ts
import { NextRequest } from "next/server";

export function proxy(request: NextRequest) {
  // উদাহরণ: /about → / page
  if (request.nextUrl.pathname === "/about") {
    return NextResponse.redirect(new URL("/", request.url));
  }
}

Auth Check

proxy.tsts
ts
import { NextRequest, NextResponse } from "next/server";

export function proxy(request: NextRequest) {
  const isLoggedIn = request.cookies.get("session");

  if (!isLoggedIn && request.nextUrl.pathname.startsWith("/dashboard")) {
    return NextResponse.redirect(new URL("/login", request.url));
  }

  return NextResponse.next();
}

export const config = {
  matcher: ["/dashboard/:path*"],
};
Edge/Node runtime

Proxy default-এ ~~Node~~ runtime-এ চলে। ভারী Node API ব্যবহার করা যায়; প্রতি request-এ চলে বলায় lightweight রাখুন।

Matcher

config.matcher দিয়ে কোন path-এ proxy চালবে তা নির্দেশ করা যায় — সব route-এ চালানোর দরকার নেই।

export const config = {
  matcher: ["/about/:path*", "/((?!_next|api).*)"],
};
শেষ প্যারায় নিজে practice করুন — কোড কপি করে নিজের এডিটরে চালিয়ে দেখুন।
আগেরStatic ও Dynamic RenderingপরেরProduction Performance
এই পেজে
Tech Tutor

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

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

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

mdanamolhasan1998@gmail.com