First Principles Checklist
"I really regret learning Next.js so soon." — A developer on Reddit
This final chapter distills everything into actionable guidance: what you should know, what you should learn, and when Next.js is (and isn't) the right choice.
What to Learn Before Next.js
Many developers jump into Next.js too early. Here's what you should know first:
1. JavaScript Fundamentals
Before any framework:
- [ ] Variables, functions, and scope
- [ ] Asynchronous programming (Promises, async/await)
- [ ] Array methods (map, filter, reduce)
- [ ] Object manipulation
- [ ] ES6+ features (destructuring, spread, modules)
- [ ] Error handling (try/catch)
2. How the Web Works
The web platform Next.js builds on:
- [ ] HTTP request/response cycle
- [ ] Status codes (200, 301, 404, 500)
- [ ] Headers (Content-Type, Cache-Control, cookies)
- [ ] DNS and domain resolution
- [ ] How browsers render pages
- [ ] The DOM and how to inspect it
3. React Fundamentals
Next.js is React—you can't skip this:
- [ ] Components and JSX
- [ ] Props and state
- [ ] Hooks (useState, useEffect, useContext)
- [ ] Event handling
- [ ] Conditional rendering
- [ ] Lists and keys
- [ ] Forms and controlled components
4. CSS and Styling
You'll need to style your applications:
- [ ] Selectors and specificity
- [ ] Box model
- [ ] Flexbox and Grid
- [ ] Responsive design
- [ ] CSS modules or Tailwind
5. TypeScript (Recommended)
Next.js has first-class TypeScript support:
- [ ] Basic types
- [ ] Interfaces and type aliases
- [ ] Generics
- [ ] Union and intersection types
- [ ] Type inference
The Fundamentals That Never Change
No matter how much frameworks evolve, these principles remain:
1. Performance Is User Experience
From Guillermo Rauch's Seven Principles:
- Server-rendered pages are not optional
- Act immediately on user input
- Don't block the main thread
2. The Rendering Equation
Every framework is solving the same equation:
Final UI = f(data, state, time)
Understanding when and where this equation is evaluated (server, client, build time, request time) is the core skill.
3. The Cache Is Always the Problem
Caching issues cause more production bugs than code bugs. Understand:
- What is cached
- Where it's cached
- When it's invalidated
- How to bypass it for debugging
4. Errors Are Information
Good error handling isn't just try/catch. It's:
- Informative error messages
- Graceful degradation
- Error boundaries
- Logging and monitoring
5. Security Is Non-Negotiable
Never trust:
- User input
- Client-side state
- Third-party data
- AI-generated code (without review)
The Next.js Mental Model
Server vs. Client
Server (default in App Router):
- Runs at build time or request time
- Has access to databases, secrets, filesystem
- Output is HTML sent to client
- Cannot use browser APIs or hooks
Client (marked with 'use client'):
- Runs in the browser
- Has access to window, localStorage, etc.
- Can use hooks and event handlers
- Contributes to bundle size
The Rendering Modes Decision Tree
Does the content change per user/request?
├── No → Does it change at all?
│ ├── No → Static (SSG)
│ └── Yes → How often?
│ ├── Rarely → ISR (revalidate: 3600)
│ └── Often → ISR (revalidate: 60)
└── Yes → Is part of it static?
├── No → SSR
└── Yes → PPR (static shell + dynamic holes)
When to Use Each Rendering Mode
| Mode | Use When | Example |
|---|---|---|
| SSG | Content never changes | Marketing pages, docs |
| ISR | Content changes periodically | Blog posts, product pages |
| SSR | Content is personalized | Dashboards, authenticated pages |
| PPR | Mix of static and dynamic | E-commerce (static product, dynamic price) |
| CSR | After-load interactivity | Complex forms, real-time features |
When to Use Next.js
Good Fit:
- SEO matters — SSR and SSG give search engines real HTML
- Performance critical — Built-in optimization for images, fonts, scripts
- Full-stack in one — API routes, server actions, database access
- Deploying to Vercel — Seamless integration
- Team knows React — Builds on existing React knowledge
- AI-assisted development — v0 and tools generate Next.js by default
Less Ideal:
- Simple static site — Consider Astro (less JavaScript)
- Heavy SPA — Create React App or Vite might be simpler
- Real-time focused — Consider dedicated frameworks
- Non-React team — Don't force React for Next.js
- Maximum control needed — Consider Remix for closer-to-platform approach
- Very simple API — Express or Hono might be overkill
Red Flags:
- You're using Next.js only because tutorials recommend it
- You don't understand why you need SSR
- You're fighting the framework's conventions
- Your team has no React experience
- You're self-hosting and finding Vercel-specific features missing
Common Beginner Mistakes
1. Using Client Components Everywhere
// Don't default to this:
'use client'; // Why? Do you actually need client interactivity?
Start with Server Components. Add 'use client' only when you need:
- Hooks
- Event handlers
- Browser APIs
2. Fetching Data in useEffect
// Old pattern (still works, but not ideal in App Router):
function Page() {
const [data, setData] = useState(null);
useEffect(() => {
fetch('/api/data').then(setData);
}, []);
}
// Better in App Router:
async function Page() {
const data = await fetch('/api/data');
return <div>{data}</div>;
}
3. Not Using Loading States
// Always provide loading UI:
// loading.js
export default function Loading() {
return <Skeleton />;
}
4. Ignoring Error Boundaries
// Always handle errors:
// error.js
'use client';
export default function Error({ error, reset }) {
return <div>Something went wrong. <button onClick={reset}>Try again</button></div>;
}
5. Over-Engineering Early
- Don't add state management until you need it
- Don't add authentication until you need it
- Don't optimize until you measure
- Start simple, add complexity when required
The Vibe Coder's Knowledge Stack
Layer 1: Must Know (Can't Outsource to AI)
- Why Server Components exist
- Hydration and how it can fail
- When to use each rendering mode
- Basic security principles
- How to read error messages
Layer 2: Should Know (AI Can Help, But You Guide)
- Data fetching patterns
- Caching strategies
- Authentication flows
- Performance optimization
- Testing approaches
Layer 3: AI Can Handle (With Your Review)
- Boilerplate generation
- Component styling
- CRUD operations
- Type definitions
- Test writing
Quick Reference Card
File Conventions (App Router)
| File | Purpose |
|---|---|
page.js |
Route UI |
layout.js |
Persistent layout |
loading.js |
Loading state |
error.js |
Error boundary |
not-found.js |
404 page |
route.js |
API endpoint |
Common Imports
import { NextRequest, NextResponse } from 'next/server';
import { cookies, headers } from 'next/headers';
import { redirect, notFound } from 'next/navigation';
import { revalidatePath, revalidateTag } from 'next/cache';
import Image from 'next/image';
import Link from 'next/link';
Caching Cheatsheet (v15+)
// No caching (default in v15+)
fetch(url);
// Cache forever
fetch(url, { cache: 'force-cache' });
// Never cache
fetch(url, { cache: 'no-store' });
// Revalidate after N seconds
fetch(url, { next: { revalidate: 60 } });
// Tag for on-demand revalidation
fetch(url, { next: { tags: ['collection'] } });
Final Thoughts
The Knowledge Investment
Learning Next.js deeply—its history, its philosophy, its internals—pays dividends that tutorials never mention:
- You debug faster — You understand why things break
- You architect better — You know the trade-offs
- You collaborate with AI effectively — You can guide and review
- You adapt to changes — Frameworks evolve, principles don't
- You make informed decisions — When to use it, when to skip it
The swyx Approach
Remember swyx's advice:
"Your tools will stop serving you well when your needs go beyond the scale and speed assumptions they were designed for. In those cases, knowing the design patterns that underlie those tools, and being able to look for new tools or make your own will come in extremely helpful."
You now have the knowledge graph. You know the who, the what, the why, the how, and the regrets. You understand the epochs and the evolution.
You're not just a Next.js user. You're someone who understands their tools.
Key Takeaways
- Learn JavaScript, web fundamentals, and React before Next.js
- Performance, caching, errors, and security are timeless fundamentals
- Use the rendering mode decision tree to choose SSG, ISR, SSR, or PPR
- Next.js is ideal for SEO, performance, and full-stack React apps
- Avoid Next.js if you're fighting its conventions or don't need its features
- AI amplifies your knowledge—understanding fundamentals makes you a better collaborator
- You now have the knowledge graph: use it to make informed decisions
Welcome to the new era of web development. Now go build something.