Review, Practice & Interview
Review, Practice & Interview
Section titled “Review, Practice & Interview”Phase Summary
Section titled “Phase Summary”This phase covered five real-world Next.js projects, progressively building up complexity:
| Project | Key Concepts | Difficulty |
|---|---|---|
| Personal Portfolio | Layouts, Server Components, Image Optimization, Server Actions | Beginner |
| Developer Blog | Markdown parsing, Dynamic routes, generateStaticParams, SEO, RSS | Beginner-Intermediate |
| Admin Dashboard | Auth.js, middleware, protected layouts, data charts, Recharts | Intermediate |
| E-commerce Store | State management (Zustand), Cart persistence, Data validation, Checkout flow | Intermediate |
| AI Chat App | AI SDK, Streaming, Server Action streams, Real-time UI | Intermediate |
Practice Tasks
Section titled “Practice Tasks”Task 1: Portfolio Enhancement
Section titled “Task 1: Portfolio Enhancement”Add a dark mode toggle to the personal portfolio project. Steps:
- Add a
ThemeTogglecomponent using'use client' - Use
localStoragefor persistence - Configure Tailwind’s
darkMode: 'class' - Add a toggle button in the header
- Style both light and dark variants of your components
Task 2: Blog Search Feature
Section titled “Task 2: Blog Search Feature”Add full-text search to the developer blog:
- Add a search input to the blog listing page
- Implement client-side filtering by title and description
- Show “no results” state when nothing matches
- Debounce the search input for performance
Task 3: Dashboard User Management
Section titled “Task 3: Dashboard User Management”Build out the users management table:
- Add an API route for listing users with pagination
- Create a Client Component table with sortable columns
- Add a search input for filtering users
- Implement a delete action with confirmation dialog
Task 4: E-commerce Cart Persistence
Section titled “Task 4: E-commerce Cart Persistence”Improve the shopping cart:
- Add a server-side cart for logged-in users
- Sync localStorage cart with the server on login
- Show cart contents across devices
- Handle merge conflicts when syncing
Task 5: AI Chat Conversation Management
Section titled “Task 5: AI Chat Conversation Management”Add conversation management to the AI chat app:
- Create a sidebar listing all conversations
- Allow creating new conversations
- Implement conversation switching
- Add conversation delete with confirmation
Interview Questions
Section titled “Interview Questions”Beginner
Section titled “Beginner”-
What is the difference between a Server Component and a Client Component in Next.js?
Server Components run on the server and can access databases, file systems, and APIs directly. They send only the rendered HTML to the browser — no JavaScript. Client Components (marked with
'use client') run in the browser and can use React hooks, manage state, and handle user interactions. -
How do you create a dynamic route in Next.js?
Create a folder with square brackets like
[slug]inside yourapp/directory. For example,app/blog/[slug]/page.tsxcreates routes like/blog/my-post. Access the dynamic parameter via theparamsprop. -
What is the purpose of
next/image?next/imageautomatically optimizes images by resizing, compressing, and converting to modern formats like WebP. It also lazy-loads images by default and provides proper responsive sizing.
Intermediate
Section titled “Intermediate”-
How would you protect API routes in Next.js?
Use Auth.js (next-auth) to verify the session in each route handler. Check
getServerSession(authOptions)and return 401 if there’s no valid session. For role-based access, check the user’s role from the session. -
Explain how streaming works with the Vercel AI SDK.
The
streamTextfunction sends a prompt to the AI API and returns an async iterable of text chunks. On the server,createStreamableValuewraps these chunks. On the client,readStreamValuereads the chunks and appends them to the UI in real-time, creating the typewriter effect. -
How do you manage state in an e-commerce cart?
Use Zustand with the
persistmiddleware for client-side state. The cart store is a single source of truth with actions for add, remove, update quantity, and clear. Thepersistmiddleware saves the cart to localStorage automatically.
Advanced
Section titled “Advanced”-
How would you implement SEO for a blog with 1000+ posts?
Use
generateStaticParamsto generate all post pages at build time. ImplementgenerateMetadatafor dynamic title and description per post. Generate a sitemap viasitemap.tsand an RSS feed via a Route Handler. Use structured data (JSON-LD) for rich search results. -
How do you handle race conditions in cart state?
Use Zustand’s built-in state updates which are synchronous within the same render cycle. For server synchronization, use optimistic updates with rollback on failure. Consider using a transaction-like pattern for multi-step cart operations.
-
What strategies would you use to reduce AI API costs in a chat application?
- Use a smaller model (gpt-4o-mini) for most conversations
- Implement conversation context windowing (only send recent messages)
- Cache common responses
- Add rate limiting per user
- Set maximum response tokens
- Use streaming to give the illusion of speed even with smaller models
Next Steps
Section titled “Next Steps”After completing these projects, you’re ready to:
- Build your own projects — Apply the patterns you’ve learned to new ideas
- Contribute to open source — Find Next.js projects on GitHub and contribute
- Explore advanced topics — Monorepos with Turborepo, micro-frontends
- Build a portfolio — Use your personal portfolio project to showcase your work