Next.js, Tailwind CSS ve shadcn/ui ile Modern Web Tasarımı
Netflix, Vercel, TikTok, Twitch ve binlerce büyük ölçekli uygulama bu teknolojileri kullanıyor. Bu derste, neden bu stack\'in bu kadar popüler olduğunu ve nasıl kullanılacağını öğreneceksiniz.
🚀 Stack Bileşenleri
Modern Stack\'in Temel Kavramları
- Next.js 15 (React Framework)
- React üzerine kurulu, production-ready özellikler sunan full-stack framework. Server Components, App Router, Server Actions, Image Optimization ve daha fazlası içerir. SEO-friendly, performanslı ve developer experience odaklı.
- Tailwind CSS v4 (Utility-First CSS)
- Utility-first yaklaşımıyla CSS yazmayı hızlandıran modern CSS framework. JIT (Just-In-Time) compiler ile sadece kullandığınız class\'ları bundle\'a dahil eder. Responsive, dark mode, animations - hepsi built-in.
- shadcn/ui (Composition Pattern)
- Kopyala-yapıştır UI component library. npm package değil, kod ownership prensibi. Radix UI üzerine kurulu, accessible, customizable ve Tailwind ile styling. İstediğiniz component\'i projenize kopyalar, tamamen sahiplenirsiniz.
- TypeScript (Type Safety)
- JavaScript\'e tip güvenliği ekler. Büyük projelerde hataları erkenden yakalar, IDE auto-complete ile geliştirme hızını artırır. Next.js ile mükemmel entegrasyon.
⚡ Neden Bu Stack?
Geleneksel vs Modern Web Geliştirme
| Geleneksel (CRA + CSS) | Modern (Next.js + Tailwind + shadcn) | |
|---|---|---|
| İlk Yükleme Hızı | ⚠️ Yavaş (client-side render) | ✅ Hızlı (SSR/SSG) |
| SEO Performansı | ❌ Zayıf (SPA sorunları) | ✅ Mükemmel (meta tags, static) |
| Development Speed | 🐌 Orta (manuel CSS yazımı) | ⚡ Çok Hızlı (utility classes) |
| Bundle Boyutu | 📦 Büyük (tüm kod client'ta) | 📦 Küçük (tree-shaking) |
| Type Safety | ❓ Opsiyonel (JavaScript) | ✅ Built-in (TypeScript) |
| UI Consistency | 🎨 Tutarsız (manuel styling) | 🎨 Tutarlı (design system) |
🏗️ Proje Kurulumu (Adım Adım)
Sıfırdan Production-Ready Next.js Projesi
Next.js Projesini Oluşturun
Next.js 15 ile yeni bir proje oluşturun. create-next-app otomatik olarak TypeScript, ESLint ve Tailwind kurulumunu yapacak:
1npx create-next-app@latest my-app23# İnteraktif sorular:4✔ Would you like to use TypeScript? Yes5✔ Would you like to use ESLint? Yes6✔ Would you like to use Tailwind CSS? Yes7✔ Would you like to use `src/` directory? Yes8✔ Would you like to use App Router? Yes9✔ Would you like to customize the default import alias? No
shadcn/ui Kurulumu
shadcn/ui CLI ile component library\'yi projenize entegre edin:
1cd my-app23# shadcn/ui initialize4npx shadcn@latest init56# İnteraktif sorular:7✔ Which style would you like to use? Default8✔ Which color would you like to use as base color? Slate9✔ Would you like to use CSS variables for colors? Yes
Bu komut, components/ui klasörünü oluşturur ve Tailwind config\'i günceller.
İlk Component\'leri Ekleyin
Sık kullanılan component\'leri projenize ekleyin:
1# Button, Card, Dialog gibi temel component'ler2npx shadcn@latest add button card dialog input label34# Tüm component'ler src/components/ui/ klasörüne kopyalanacak5# Artık bunları istediğiniz gibi özelleştirebilirsiniz!
Development Server\'ı Başlatın
Projenizi çalıştırın ve tarayıcıda görün:
1npm run dev23# ✓ Ready in 1.2s4# ○ Local: http://localhost:300056# Tarayıcınızda açın: http://localhost:3000
Next.js Turbopack ile super hızlı hot-reload. Kod değişikliklerinizi anında göreceksiniz!
💻 İlk Component\'inizi Oluşturun
Şimdi öğrendiklerinizi pratiğe dökelim! shadcn button ve card component\'lerini kullanarak basit bir hero section oluşturalım:
1import { Button } from '@/components/ui/button';2import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';34export function HeroSection() {5 return (6 <section className="container mx-auto px-4 py-20">7 <div className="max-w-4xl mx-auto text-center space-y-8">8 {/* Gradient başlık - Tailwind utilities */}9 <h1 className="text-5xl font-bold bg-gradient-to-r from-blue-600 to-purple-600 bg-clip-text text-transparent">10 Modern Web Tasarımına Hoş Geldiniz11 </h1>1213 <p className="text-xl text-muted-foreground max-w-2xl mx-auto">14 Next.js, Tailwind CSS ve shadcn/ui ile profesyonel, performanslı15 ve güzel web uygulamaları oluşturun.16 </p>1718 {/* shadcn Button component'i */}19 <div className="flex gap-4 justify-center">20 <Button size="lg" className="text-lg">21 Hemen Başla22 </Button>23 <Button size="lg" variant="outline" className="text-lg">24 Daha Fazla Öğren25 </Button>26 </div>2728 {/* shadcn Card component'i */}29 <div className="grid md:grid-cols-3 gap-6 mt-16">30 <Card>31 <CardHeader>32 <CardTitle>⚡ Super Hızlı</CardTitle>33 <CardDescription>34 Server Components ile lightning-fast yükleme35 </CardDescription>36 </CardHeader>37 <CardContent>38 <p className="text-sm text-muted-foreground">39 Next.js optimizasyonları sayesinde kullanıcılarınız40 anında içeriğe ulaşır.41 </p>42 </CardContent>43 </Card>4445 <Card>46 <CardHeader>47 <CardTitle>🎨 Güzel Tasarım</CardTitle>48 <CardDescription>49 Tailwind ile pixel-perfect UI50 </CardDescription>51 </CardHeader>52 <CardContent>53 <p className="text-sm text-muted-foreground">54 Utility-first yaklaşım ile hızlı ve tutarlı55 tasarım sistemi.56 </p>57 </CardContent>58 </Card>5960 <Card>61 <CardHeader>62 <CardTitle>♿ Erişilebilir</CardTitle>63 <CardDescription>64 WCAG 2.1 AA standardında65 </CardDescription>66 </CardHeader>67 <CardContent>68 <p className="text-sm text-muted-foreground">69 shadcn/ui Radix primitives kullanır, tüm70 accessibility standartları built-in.71 </p>72 </CardContent>73 </Card>74 </div>75 </div>76 </section>77 );78}
🎨 Tailwind CSS Utility-First Yaklaşımı
Tailwind CSS, geleneksel CSS yazımından farklı bir yaklaşım sunar. Stil yazmak yerine, önceden tanımlanmış utility class\'ları kullanırsınız:
1// Tailwind ile (önerilen)2function Card() {3 return (4 <div className="p-6 rounded-lg shadow-lg bg-white dark:bg-slate-800 hover:shadow-xl transition-shadow">5 <h2 className="text-2xl font-bold text-slate-900 dark:text-white mb-4">6 Başlık7 </h2>8 <p className="text-slate-600 dark:text-slate-300 leading-relaxed">9 İçerik buraya gelecek...10 </p>11 </div>12 );13}1415// Avantajlar:16// ✅ Hızlı geliştirme (class ismi düşünmeye gerek yok)17// ✅ Tutarlı design system (spacing, colors standardize)18// ✅ Responsive built-in (md:, lg: prefix'leri)19// ✅ Dark mode built-in (dark: prefix)20// ✅ Tree-shaking (kullanılmayan CSS bundle'a dahil edilmez)
🧩 shadcn/ui Composition Pattern
shadcn/ui\'ın en güçlü özelliği: composition pattern. Component\'leri parçalara böler, istediğiniz gibi birleştirirsiniz:
1import {2 Card,3 CardContent,4 CardDescription,5 CardFooter,6 CardHeader,7 CardTitle8} from '@/components/ui/card';9import { Button } from '@/components/ui/button';10import { Badge } from '@/components/ui/badge';1112export function ProductCard({ product }: { product: Product }) {13 return (14 <Card className="overflow-hidden">15 {/* Composition: Card parçalarını istediğiniz gibi düzenleyin */}16 <CardHeader className="p-0">17 <img18 src={product.image}19 alt={product.name}20 className="w-full h-48 object-cover"21 />22 </CardHeader>2324 <CardContent className="p-6">25 <div className="flex items-start justify-between mb-2">26 <CardTitle className="text-xl">{product.name}</CardTitle>27 <Badge variant={product.inStock ? "default" : "secondary"}>28 {product.inStock ? "Stokta" : "Tükendi"}29 </Badge>30 </div>3132 <CardDescription className="line-clamp-2">33 {product.description}34 </CardDescription>3536 <div className="mt-4 flex items-center justify-between">37 <span className="text-2xl font-bold">38 ₺{product.price.toLocaleString()}39 </span>40 <span className="text-sm text-muted-foreground">41 {product.rating} ⭐ ({product.reviews} değerlendirme)42 </span>43 </div>44 </CardContent>4546 <CardFooter className="p-6 pt-0 flex gap-2">47 <Button className="flex-1" disabled={!product.inStock}>48 Sepete Ekle49 </Button>50 <Button variant="outline" size="icon">51 <Heart className="w-4 h-4" />52 </Button>53 </CardFooter>54 </Card>55 );56}5758// Composition Pattern Avantajları:59// ✅ Esnek yapı (istediğiniz sırada kullanın)60// ✅ Özelleştirilebilir (her parça ayrı className alır)61// ✅ Type-safe (TypeScript intellisense)62// ✅ Accessible (ARIA otomatik)63// ✅ Kod sahipliği (istediğiniz değişikliği yapın)
🔥 Server Components vs Client Components
Next.js 15\'in en devrim niteliğindeki özelliği: React Server Components. Component\'lerinizi sunucuda veya client\'ta render edebilirsiniz:
1// Server Component (default - directive yok)2// Sunucuda render edilir, JavaScript browser'a gönderilmez34async function BlogPage() {5 // API çağrısı doğrudan sunucuda6 const posts = await fetch('https://api.example.com/posts', {7 next: { revalidate: 60 } // 60 saniyede bir yenile (ISR)8 }).then(res => res.json());910 return (11 <div className="container mx-auto py-12">12 <h1 className="text-4xl font-bold mb-8">Blog</h1>1314 <div className="grid md:grid-cols-2 lg:grid-cols-3 gap-6">15 {posts.map((post) => (16 <article key={post.id} className="border rounded-lg p-6">17 <h2 className="text-2xl font-bold mb-2">{post.title}</h2>18 <p className="text-muted-foreground mb-4">{post.excerpt}</p>19 <time className="text-sm text-muted-foreground">20 {new Date(post.date).toLocaleDateString('tr-TR')}21 </time>22 </article>23 ))}24 </div>25 </div>26 );27}2829export default BlogPage;3031// Server Component Avantajları:32// ✅ Bundle size küçük (JS kodu client'a gönderilmez)33// ✅ SEO friendly (HTML olarak render edilir)34// ✅ Database/API erişimi doğrudan (auth token güvenli)35// ✅ Hızlı ilk yükleme (server rendering)36// ✅ Otomatik code splitting
\'use client\' ekleyin. Bu, bundle size\'ı küçültür ve performance\'ı artırır!📱 Responsive Design (Mobile-First)
Tailwind CSS, responsive tasarımı son derece kolay hale getirir. Breakpoint prefix\'leri kullanarak farklı ekran boyutlarına özel stiller uygulayabilirsiniz:
1export function ResponsiveGrid() {2 return (3 <div className="4 // Mobile (default - prefix yok)5 grid grid-cols-1 gap-4 p-467 // Tablet (768px+)8 md:grid-cols-2 md:gap-6 md:p-6910 // Desktop (1024px+)11 lg:grid-cols-3 lg:gap-8 lg:p-81213 // Large Desktop (1280px+)14 xl:grid-cols-4 xl:gap-10 xl:p-1015 ">16 <Card>Item 1</Card>17 <Card>Item 2</Card>18 <Card>Item 3</Card>19 <Card>Item 4</Card>20 </div>21 );22}2324// Responsive Typography25function ResponsiveText() {26 return (27 <h1 className="28 text-2xl // Mobile: 24px29 md:text-3xl // Tablet: 30px30 lg:text-4xl // Desktop: 36px31 xl:text-5xl // Large: 48px3233 font-bold34 leading-tight // Line height3536 mb-4 // Mobile: 16px margin37 md:mb-6 // Tablet: 24px38 lg:mb-8 // Desktop: 32px39 ">40 Responsive Başlık41 </h1>42 );43}4445// Breakpoints (Tailwind default):46// sm: 640px+47// md: 768px+48// lg: 1024px+49// xl: 1280px+50// 2xl: 1536px+
🎨 Dark Mode (Otomatik)
Tailwind CSS ve shadcn/ui ile dark mode desteği built-in. dark: prefix\'i kullanarak dark mode stilleri eklersiniz:
1export function ThemeAwareCard() {2 return (3 <div className="4 // Light mode (default)5 bg-white text-slate-900 border-slate-20067 // Dark mode (dark: prefix)8 dark:bg-slate-800 dark:text-white dark:border-slate-700910 rounded-lg border p-611 ">12 <h2 className="13 text-2xl font-bold mb-414 text-blue-600 // Light mode15 dark:text-blue-400 // Dark mode (daha açık ton)16 ">17 Dark Mode Destekli Başlık18 </h2>1920 <p className="21 text-slate-600 // Light mode22 dark:text-slate-300 // Dark mode23 ">24 Bu metin hem light hem dark mode'da güzel görünür.25 </p>26 </div>27 );28}2930// Dark mode nasıl çalışır?31// 1. Tailwind config'de darkMode: 'class' ayarı32// 2. HTML root'a .dark class'ı eklenir33// 3. next-themes paketi ile otomatik theme switching
⚡ Performance Best Practices
1. Image Optimization
1import Image from 'next/image';23// ❌ Kötü: Normal img tag4<img src="/hero.jpg" alt="Hero" />56// ✅ İyi: Next.js Image component7<Image8 src="/hero.jpg"9 alt="Hero"10 width={1200}11 height={600}12 priority // Above-the-fold images için13 placeholder="blur" // Loading sırasında blur effect14/>
2. Font Optimization
1import { Inter } from 'next/font/google';23// Next.js otomatik font optimization4const inter = Inter({5 subsets: ['latin'],6 display: 'swap', // FOUT önleme7 variable: '--font-inter',8});910export default function RootLayout({ children }) {11 return (12 <html lang="tr" className={inter.variable}>13 <body className="font-sans">{children}</body>14 </html>15 );16}
3. Code Splitting (Lazy Loading)
1import dynamic from 'next/dynamic';23// Heavy component'leri lazy load edin4const HeavyChart = dynamic(() => import('./HeavyChart'), {5 loading: () => <div>Yükleniyor...</div>,6 ssr: false // Client-side only7});89export function Dashboard() {10 return (11 <div>12 <h1>Dashboard</h1>13 <HeavyChart /> {/* İlk render'da yüklenmez */}14 </div>15 );16}
✅ Kalite Kontrol (Linting & Type Check)
Kod kalitesini sürekli kontrol altında tutmak için şu komutları düzenli çalıştırın:
1# TypeScript type check2npm run typecheck34# ESLint ile kod kalitesi5npm run lint6npm run lint --fix # Otomatik düzelt78# Tümünü birlikte (pre-commit hook için)9npm run typecheck && npm run lint1011# Production build test12npm run build1314# Lighthouse audit (performance)15npm run dev16# Chrome DevTools > Lighthouse > Run audit
🎓 Özet ve Sonraki Adımlar
- ✅ Next.js 15 Server Components ve App Router
- ✅ Tailwind CSS v4 utility-first approach
- ✅ shadcn/ui composition pattern
- ✅ TypeScript type safety
- ✅ Responsive design ve dark mode
- ✅ Performance best practices
📚 Sonraki Dersler
- 🎨Advanced Tailwind Patterns: Custom utilities, plugins, design tokens, theme customization
- 🧩shadcn Component Deep Dive: Form validation, dialog modals, data tables, command palette
- 🚀Next.js Production Deployment: Vercel deployment, environment variables, analytics, monitoring