Next.js Discord

Discord Forum

Prerender error

Answered
JackO posted this in #help-forum
Open in Discord
Keep getting this cancerous prerender error, I wish I knew what was causing it seems like each time I run npm run build I get a different page that tries to render and then throws this error. GPT said it was related to NextResponse not having a defined status, but I made sure that there was a html status code for every NextResponse, so that shouldn't be an issue anymore. I've been getting these chunk errors for hours. Any idea for a fix? Would re-enabling lint and going through all of those errors help fix anything?

Also, I've noticed that ever since the most recent version of next (or even sooner), I am getting way more linting problems when building, specifically with use cases where I use <Icon className=""> where Icon is defined as an icon attribute in an array mapping of objects and the icon attribute is defined with type React.ElementType. These used to take the className arg just fine, but for some reason now they are all throwing lint errors. Is this a change that happened to linting or React.ElementType that I missed?
Answered by JackO
The problem was a next-auth session provider that was in a ClientComponent but the useSession hook was being called in a place that did not have <AuthProvider> wrapped in a higher level layout. For some reason I wasn't told this until actually investigating but this was the cause.
View full answer

1 Reply

The problem was a next-auth session provider that was in a ClientComponent but the useSession hook was being called in a place that did not have <AuthProvider> wrapped in a higher level layout. For some reason I wasn't told this until actually investigating but this was the cause.
Answer