Back to Blog
    Web Development

    Next.js 15 App Router: Complete Guide to Server Components, Streaming & Edge Runtime

    Mortex Solutions TeamMarch 20, 202614 min read
    Next.js 15 App Router: Complete Guide to Server Components, Streaming & Edge Runtime

    Next.js 15 with the App Router has fundamentally changed how we build React applications. Server Components are the default, streaming SSR delivers instant page loads, and edge runtime puts your app closer to users worldwide.

    Next.js 15 code development

    🚀 What's New in Next.js 15

    • Turbopack — 10x faster dev builds (now stable)
    • Partial Prerendering — Static shell + dynamic streaming
    • Server Actions — Mutations without API routes
    • Enhanced Caching — Granular cache control
    • React 19 Integration — use() hook, async components

    📁 App Router File Structure

    app/
    ├── layout.tsx          # Root layout (Server Component)
    ├── page.tsx            # Home page
    ├── loading.tsx         # Instant loading UI
    ├── error.tsx           # Error boundary
    ├── not-found.tsx       # 404 page
    ├── dashboard/
    │   ├── layout.tsx      # Nested layout
    │   ├── page.tsx        # /dashboard
    │   ├── @analytics/     # Parallel route
    │   │   └── page.tsx
    │   └── @team/          # Parallel route
    │       └── page.tsx
    ├── blog/
    │   ├── page.tsx        # /blog (list)
    │   └── [slug]/
    │       └── page.tsx    # /blog/:slug (dynamic)
    └── api/
        └── webhook/
            └── route.ts    # API endpoint

    💻 Server Components + Data Fetching

    // app/blog/page.tsx — Server Component (default)
    import { db } from '@/lib/database';
    
    // This runs on the server — no client JS shipped!
    export default async function BlogPage() {
      const posts = await db.post.findMany({
        orderBy: { createdAt: 'desc' },
        take: 20
      });
    
      return (
        <main>
          <h1>Blog</h1>
          {posts.map(post => (
            <article key={post.id}>
              <h2>{post.title}</h2>
              <p>{post.excerpt}</p>
            </article>
          ))}
        </main>
      );
    }
    
    // Metadata for SEO
    export async function generateMetadata({ params }) {
      return {
        title: 'Blog | My App',
        description: 'Latest articles and tutorials',
      };
    }

    ⚡ Server Actions for Mutations

    'use server';
    
    import { revalidatePath } from 'next/cache';
    import { db } from '@/lib/database';
    
    export async function createPost(formData: FormData) {
      const title = formData.get('title') as string;
      const content = formData.get('content') as string;
    
      await db.post.create({
        data: { title, content, published: true }
      });
    
      revalidatePath('/blog');
    }
    
    // Usage in component:
    // <form action={createPost}>
    //   <input name="title" />
    //   <textarea name="content" />
    //   <button type="submit">Publish</button>
    // </form>

    📊 Next.js 15 vs Remix vs Astro

    FeatureNext.js 15RemixAstro
    SSR✅ Streaming✅ Progressive✅ On-demand
    Server Components✅ Default❌✅ Islands
    Edge Runtime✅ Full✅ Full⚠️ Limited
    Static Export✅❌✅ Default
    💡 Pro Tip: Use Partial Prerendering for the best of both worlds — static shell loads instantly while dynamic content streams in. This is the future of web performance.