Create React App → Next.js
mediumCRA is dead. Next.js gives you SSR, SSG, API routes, and a production-ready setup. Most effort is restructuring routing and deciding Pages vs App Router.
Estimated: 4-10h · 7 steps
Progress0%
Step 1: Install Next.js
npx create-next-app@latest my-app --typescript && npm uninstall react-scripts
Step 2: Migrate file structure
Move src/components, src/hooks, src/utils as-is. Create app/ (or pages/) directory. Each route = a file.
Step 3: Port routing
React Router routes → Next.js file-based routes. <Link> from next/link. useNavigate → useRouter from next/navigation.
Step 4: Replace env vars
REACT_APP_ → NEXT_PUBLIC_ for client-side vars. Server-only vars have no prefix.
find src -name '*.ts*' -exec sed -i 's/process.env.REACT_APP_/process.env.NEXT_PUBLIC_/g' {} +Step 5: Move index.html content
Put <head> content in app/layout.tsx using Next.js Metadata API. Global CSS in app/globals.css.
Step 6: Set up API routes
Move any CRA proxied endpoints to app/api/route.ts. Replace fetch('/api/x') with same — routing matches automatically.
Step 7: Test build
npm run build && npm run start
✓ All pages render, no missing env vars, API routes respond