Next.js Build Error After Changes
After Cursor refactored your Next.js application, the build command fails. The application won't build for production.
The refactored code violates Next.js requirements or broke the build configuration.
Error Messages You Might See
Common Causes
- Server component using client-only code (window, hooks in server)
- API route using wrong export (named instead of default)
- Image dimensions not specified (if using Image component)
- Dynamic import syntax incorrect for Next.js
- Environment variables not exposed to client
How to Fix It
Add 'use client' directive for client components. API routes: export default function handler(req, res) {}. Images: use next/image with width/height. Dynamic imports: dynamic(() => import('component'), {ssr: false}). Env: prefix with NEXT_PUBLIC_ for client access.
Real developers can help you.
You don't need to be technical. Just describe what's wrong and a verified developer will handle the rest.
Get HelpFrequently Asked Questions
What's the difference between server and client components?
Server components (default) run on server, no bundle size cost. Client need 'use client' directive, bundle included. Use server when possible.
How do I use environment variables in Next.js?
Prefix with NEXT_PUBLIC_ to expose to client. Access with process.env.NEXT_PUBLIC_VAR in browser.