Next.js Discord

Discord Forum

Error: Clerk: auth() and currentUser() are only supported in App Router (/app directory).

Answered
Yellowhead catfish posted this in #help-forum
Open in Discord
Yellowhead catfishOP
Guys, can anyone tell me why when I add output: 'export' to next.config, Clerk gives an error with the Middleware

⨯ Middleware cannot be used with "output: export". See more info here: https://nextjs.org/docs/advanced-features/static-html-export

Error: Clerk: auth() and currentUser() are only supported in App Router (/app directory).
If you're using /pages, try getAuth() instead.
Original error: Error: Route / with `dynamic = "error"` couldn't be rendered statically because it used `headers`. See more info here: https://nextjs.org/docs/app/building-your-application/rendering/static-and-dynamic#dynamic-rendering
Answered by gin
deploy with vercel or netlify
View full answer

43 Replies

Yellowhead catfishOP
help plss
Asian black bear
I think error message is giving you the exact reason.
@Asian black bear I think error message is giving you the exact reason.
Yellowhead catfishOP
So I don't use auth() and currentUser() anywhere
@Yellowhead catfish So I don't use auth() and currentUser() anywhere
u cannot use auth() or any other dynamic function with a static export
@Yellowhead catfish So I don't use auth() and currentUser() anywhere
Yellowhead catfishOP
I use only ClerkProvider, UserButton, SignedOut, SignInButton and OrganizationSwitcher
@gin u cannot use auth() or any other dynamic function with a static export
Yellowhead catfishOP
So what should I do if I don’t use auth() anywhere? but only the above
@Yellowhead catfish So what should I do if I don’t use auth() anywhere? but only the above
you remove output: "export" from your next config
@gin you remove output: "export" from your next config
Yellowhead catfishOP
try now
I added this to deploy to github pages (action)
maybe it will work without it
it wont
github pages is for static files indeed
deploy with vercel or netlify
Answer
Yellowhead catfishOP
@gin deploy with vercel or netlify
Yellowhead catfishOP
vercel won't let me register XD
thats maybe a vercel issue u can ask in here
Yellowhead catfishOP
weird
its also free
Yellowhead catfishOP
That's right, there's netlify
thank
@Yellowhead catfish That's right, there's netlify
but keep in mind
they have a bandwidth limit
and im not sure if pure requests also count
maybe try with a different email for vercel
ngl
Yellowhead catfishOP
Yellowhead catfishOP
eeeee
this work
Netlify successfully deployed
u can mark my answer as solution :
)
Yellowhead catfishOP
Ye
How? 😅
@Yellowhead catfish How? 😅
like this
Yellowhead catfishOP
Thanks again