Skip to content
Home / Migrations / Create React AppNext.js

Create React App Next.js

medium

CRA 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

What this migration involves

Moving from Create React App to Next.js is rated medium and takes about 4-10h on a typical project. The guide breaks it into 7 steps, 3 of which ship with runnable commands and 1 with a verification check.

FAQ

How long does migrating from Create React App to Next.js take?

Around 4-10h for a typical project — 7 steps, difficulty rated medium, 3 of them with copy-paste commands.

Is moving from Create React App to Next.js reversible?

No reverse guide is tracked yet, so treat this as a one-way move and keep a full export of your Create React App data before you start.

What does Next.js cost compared to Create React App?

Next.js: open-source from $0/mo, free plan available.