Next.jsAdvanced
Next.js Configuration
next.config.ts — images, redirects, rewrites, experimental options বাংলায়।
10টি অংশবাংলা ভাষায়
next.config.ts হলো Next.js-এর central configuration file। এতে project-এর behavior কাস্টমাইজ করা যায়।
মৌলিক Config
next.config.tsts
ts
import type { NextConfig } from "next";
const nextConfig: NextConfig = {
// এখানে options
};
export default nextConfig;Common Options
next.config.tsts
ts
import type { NextConfig } from "next";
const nextConfig: NextConfig = {
images: {
remotePatterns: [
{
protocol: "https",
hostname: "res.cloudinary.com",
},
],
},
redirects: async () => [
{
source: "/old-about",
destination: "/about",
permanent: true,
},
],
cacheComponents: true,
};
export default nextConfig;Redirects ও Rewrites
| Feature | কাজ |
|---|---|
| redirects | এক URL আরেক URL-এ পাঠায় |
| rewrites | URL change না করে ভিন্ন source |
| headers | Custom HTTP headers |
Image Remote Patterns
External domain থেকে image দেখাতে next/image-এ remotePatterns সেট করতে হয়।
TypeScript Support
next.config.ts (TypeScript) supported — config-এ type safety পাবেন। Template literal ব্যবহার করে placeholder দিলেও সম্পূর্ণ typing অব্যাহত থাকে।
শেষ প্যারায় নিজে practice করুন — কোড কপি করে নিজের এডিটরে চালিয়ে দেখুন।