18. Migration Patterns
You will be asked about migrations constantly. Know these patterns.
18.1 Create React App → Next.js App Router
The most common migration request. CRA is end-of-life.
Phases:
- Add Next.js alongside CRA (incremental adoption)
- Move routes one by one (
/login,/dashboard) - Identify SSG vs ISR vs SSR per route
- Replace API calls with Server Components where possible
- Add Middleware for auth (replace manual route guards)
- Migrate to Next.js Image, Font, and Link
18.2 Gatsby → Next.js
- Gatsby's GraphQL data layer → Server Components with direct data fetching
- Gatsby static generation → Next.js SSG/ISR
- Gatsby plugins → Next.js equivalents or direct integrations
18.3 Self-hosted Next.js → Vercel
Common with teams running Next.js on AWS, GCP, or their own servers.
What they gain:
- ISR that actually distributes globally (self-hosted ISR is single-region)
- Preview deployments (impossible on self-hosted without significant tooling)
- Zero-config builds
- Skew protection
- Automatic image optimisation at the CDN level
Migration: Usually zero code changes. Point DNS to Vercel.
18.4 Pages Router → App Router
The most common Next.js-specific migration:
- Incremental — migrate one route at a time
pages/andapp/directories coexist- Data fetching changes:
getServerSideProps→ async Server Components,getStaticProps→ SSG Server Components