Create Next App Next 14 Build Error

When generating a new app with the create next app command npx create-next-app@latest -e with-supabase, there are multiple build errors when running next build. Errors below
Error occurred prerendering page "/login". Read more: https://nextjs.org/docs/messages/prerender-error
TypeError: Cannot read properties of null (reading 'useContext')

Error occurred prerendering page "/_not-found". Read more: https://nextjs.org/docs/messages/prerender-error
TypeError: Cannot read properties of null (reading 'useContext')

Error occurred prerendering page "/". Read more: https://nextjs.org/docs/messages/prerender-error
TypeError: Cannot read properties of null (reading 'useContext')

Error occurred prerendering page "/500". Read more: https://nextjs.org/docs/messages/prerender-error
Error: <Html> should not be imported outside of pages/_document.

Error: <Html> should not be imported outside of pages/_document.
Read more: https://nextjs.org/docs/messages/no-document-import-in-page

Error occurred prerendering page "/404". Read more: https://nextjs.org/docs/messages/prerender-error
Error: <Html> should not be imported outside of pages/_document.
Error occurred prerendering page "/login". Read more: https://nextjs.org/docs/messages/prerender-error
TypeError: Cannot read properties of null (reading 'useContext')

Error occurred prerendering page "/_not-found". Read more: https://nextjs.org/docs/messages/prerender-error
TypeError: Cannot read properties of null (reading 'useContext')

Error occurred prerendering page "/". Read more: https://nextjs.org/docs/messages/prerender-error
TypeError: Cannot read properties of null (reading 'useContext')

Error occurred prerendering page "/500". Read more: https://nextjs.org/docs/messages/prerender-error
Error: <Html> should not be imported outside of pages/_document.

Error: <Html> should not be imported outside of pages/_document.
Read more: https://nextjs.org/docs/messages/no-document-import-in-page

Error occurred prerendering page "/404". Read more: https://nextjs.org/docs/messages/prerender-error
Error: <Html> should not be imported outside of pages/_document.
12 Replies
lucasb
lucasbOP2y ago
Export encountered errors on following paths:
/_error: /404
/_error: /500
/_not-found
/login/page: /login
/page: /
Export encountered errors on following paths:
/_error: /404
/_error: /500
/_not-found
/login/page: /login
/page: /
lucasb
lucasbOP2y ago
Corrupted
Corrupted2y ago
must be something wrong with the create script because ive updated all my dependencies to the latest versions (nextjs is on 14, and supabase is on 2.38.4) and everything works. granted ive had this project working before next 14
lucasb
lucasbOP2y ago
Possibly.. but I have the same setup as you.. updated my dependecies in my project to the latest versions (next14, supabase ssr, etc) and I am still seeing the error. I pulled down the template and ran it to try and see if it was my setup or the template It's strange to me the supabase team would push all of this and not even try to test if next build runs without error I'm currently on:
"@supabase/ssr": "0.0.10",
"@supabase/supabase-js": "2.38.4",
"next": "14.0.2"
"@supabase/ssr": "0.0.10",
"@supabase/supabase-js": "2.38.4",
"next": "14.0.2"
what about you @Corrupted ?
Corrupted
Corrupted2y ago
oh, im not using @supabase/ssr i have not attempted to use it because things are working for me already how i want them to. i have seen lots of people having issues with the ssr package though. but here are the versions im on anyway
"@supabase/auth-helpers-nextjs": "^0.8.4",
"@supabase/supabase-js": "^2.38.4",
"next": "^14.0.1",
"@supabase/auth-helpers-nextjs": "^0.8.4",
"@supabase/supabase-js": "^2.38.4",
"next": "^14.0.1",
lucasb
lucasbOP2y ago
ahh gotcha. They were pushing their new ssr package and deprecated the auth-helpers-nextjs lib so i figured i would give it a try.
Corrupted
Corrupted2y ago
if you're starting new and just want to get things started, i would start with the auth-helpers and when the kinks are ironed out in the SSR, then upgrade to it with their migration guide. auth-helpers was pretty easy to setup and use, so thats why im still using it
Corrupted
Corrupted2y ago
Supabase Auth with the Next.js App Router<!-- --> | Supabase Docs
Authentication and Authorization helpers for creating an authenticated Supabase client with the Next.js 13 App Router.
lucasb
lucasbOP2y ago
I'm not starting new, i've had the auth-helpers lib working in my repo's for a while.. just wanted to try the ssr/next14 setup appreciate the link though
Corrupted
Corrupted2y ago
ah okay, gotcha. np!
lucasb
lucasbOP2y ago
ironically, the project does compile with next build when deployed to vercel. must be a nextjs issue
RayTheGreat
RayTheGreat2y ago
I'm having the hardest time getting supabase Auth to work in next JS. I can get login/logout working but passing cookies seems too complicated.

Did you find this page helpful?