How I moved my portfolio site from Create React App to Next.js
My personal site, diyorjon.uz, ran on Create React App for several years. It loaded, it looked fine, and I never looked inside. When I started moving it to Next.js and went through the code, I found a few embarrassing things.
What turned up before the move
The worst was the contact form: it sent nothing at all and just showed "successfully". If anyone wrote to me through it, the message never arrived. The email and phone labels on the form were swapped, too.
The meta tags pointed to og-image.jpg, but the file didn't exist, so links on Telegram showed up without a picture. The
favicon was hotlinked from istockphoto, watermark included. An old build/ folder was committed to the repo,
package-lock.json was out of sync, and npm ci didn't work. The text had "Frontent", "throuhg" and a hard-coded "@2024",
and the mobile menu stayed open after moving to another page.
Why the move was needed
CRA renders only in the browser. Google and Telegram saw an empty <div id="root"> and the same title on every page;
/about, /resume and /blogs had no title or description of their own. npm audit reported 104 vulnerabilities,
5 of them critical, most of them through react-scripts, and CRA is no longer maintained. The libraries were old too:
React 17, React Router v5, Material-UI v4, and MUI v4 doesn't get along with React 18.
I went with Next.js (App Router) and TypeScript. The site was already on Vercel, every page becomes ready HTML at build time, and metadata is written per page.
The move
My main rule was to leave the design alone. All the styles were in styled-components, and to avoid rewriting them I used
a styled-components registry in the App Router: styles are collected during server rendering and injected into the HTML.
Components stayed 'use client' but still render on the server. To check the result, I took Playwright screenshots of
the old and new versions at the same sizes and compared them side by side.
It turned out only icons, Switch and IconButton were used from MUI. I replaced the icons with react-icons and wrote
my own 40-line Switch, which was enough instead of a whole UI library.
The Next.js file structure (app/about/page.tsx, app/blogs/[slug]/page.tsx) took over from React Router, and Link plus
usePathname() took over from NavLink. The theme used to live in useState and was lost on refresh. Now next-themes
keeps it, and the colours don't flash when a page loads.
For SEO every page got title, description, canonical, Open Graph and Twitter tags. sitemap.xml and robots.txt
are generated from code instead of written by hand, and blog posts carry JSON-LD (BlogPosting).
Result
npm audit went from 104 to 0, every page ships as ready HTML with its own meta tags, and the design didn't change. The
form now sends messages to my Telegram bot. The blog moved to MDX, so a new post is a single new file.
If you have an old CRA project too, click through it yourself from start to finish before you migrate. If I hadn't started the move, I don't know how much longer I'd have gone without noticing the form was broken.