How React Devs Learn the Next.js App Router Fast
For React developers new to Next.js · Based on Codynn Next.js Full-Stack App Builder
// TL;DR
If you already know React but are new to Next.js, this framework maps your existing knowledge onto the App Router's conventions. You'll learn that folders are routes, page.tsx is the reserved page filename, components are Server Components by default, and 'use client' is the opt-in for hooks and interactivity. It replaces React Router config with file-based routing and adds built-in data fetching, API routes, and SEO metadata. Use it to make fast, correct decisions about rendering strategy and project structure instead of trial-and-error.
What changes when I move from React to the Next.js App Router?
The biggest shift is that you stop writing router configuration entirely. In the Next.js App Router, the folder is the route. Create `app/about/page.tsx` and `/about` is live — no `
The second shift is rendering. In plain React, every component ships to the browser. In Next.js, every component is a Server Component by default — it renders on the server, can directly `await` data, and never ships its JavaScript to the client. You only add `'use client'` at the top of a file when the component needs `useState`, `useEffect`, event handlers like `onClick`, or browser APIs.
How do I structure a Next.js project correctly?
Start by scaffolding with `npx create-next-app@latest` and accepting the recommended settings. Then map your route tree as folders:
- Static route: `app/about/` → `/about`
- Nested route: `app/about/team/` → `/about/team`
- Dynamic route: `app/blog/[slug]/` → `/blog/anything`
- Catch-all route: `app/docs/[...slug]/` → `/docs/any/depth`
- Organization-only group: `app/(marketing)/pricing/` → `/pricing`
Inside each route folder, create a file named exactly `page.tsx` with a default-exported function. The filename is non-negotiable — anything else is treated as a co-located module, not a page.
Then set up `app/layout.tsx` for global elements: your site-wide navbar, global CSS, and fonts imported from `next/font/google` so they're self-hosted at build time with no layout shift.
How do I handle the hooks I already know from React?
Your React hooks still work, but they require a Client Component. `useState` and `useEffect` need `'use client'` at the top of the file. Next.js adds navigation hooks from `'next/navigation'`:
- `useRouter` for programmatic navigation — `router.push('/dashboard')` after login, `router.back()` for the back button.
- `usePathname` to read the current path.
- `useSearchParams` to read query strings — `searchParams.get('category')`.
All three require `'use client'`. The key optimization is to push `'use client'` down the tree: extract only the interactive leaf into a client component and render it inside a Server Component page, so the page itself stays server-rendered.
How does dynamic routing work in practice?
For a blog, create `app/blog/[slug]/page.tsx`. Declare the function `async`, type `params` as `Promise<{ slug: string }>`, and `await params` to extract the slug — remember, params is a Promise in modern Next.js. One file handles every post URL. For arbitrarily deep docs paths, use `[...slug]` and type params as `Promise<{ slug: string[] }>`, then `slug.join('/')` to rebuild the path.
What about navigation and SEO?
For SEO, export a `metadata` object from any `page.tsx`: `export const metadata: Metadata = { title, description }`. Next.js renders it as server-side HTML in the `
`, exactly what crawlers need. Never write manual head tags.Next step: Scaffold a fresh project with `create-next-app`, recreate three routes — one static, one dynamic, one Route Group — and convert a familiar React component into a Server Component to feel the difference.
// FREQUENTLY ASKED QUESTIONS
Do my existing React components work in Next.js?
Yes, but by default they become Server Components, which can't use hooks or event handlers. Any component relying on useState, useEffect, or onClick needs 'use client' at the top. Components that only render UI from props or fetched data work unchanged as Server Components and benefit from smaller client bundles.
Is React Router still needed in Next.js?
No. The Next.js App Router replaces React Router entirely with file-based routing. Folders map to URLs, so you never write route config. For navigation use the Link component for clicks and the useRouter hook for programmatic redirects — both built into Next.js from 'next/navigation'.
Where do I fetch data now that there's no useEffect by default?
Fetch data directly in Server Components by making the component async and awaiting your data source. This runs on the server, keeps API keys secure, and ships no fetching code to the browser. Only use useEffect in a Client Component when the data depends on browser state or user interaction.