#Next.js 15 (Canary) - Issue with Convex Auth Context

14 messages · Page 1 of 1 (latest)

ashen shuttle
#

I'm using Next.js 15 (canary version), and everything works fine most of the time. However, occasionally after a hard reload, the middleware indicates the user is authenticated, but mutations fail because the ctx.user is undefined. For example, inside a mutation:
...
const userId = await getAuthUserId(ctx)
...
returns undefined, This issue seems to resolve itself after a few refreshes.

What could be causing this behavior?

I'm using:
"@auth/core": "^0.37.4",
"@convex-dev/auth": "^0.0.75",
"convex": "^1.17.3",
"convex-helpers": "^0.1.65",

timber oysterBOT
#

Thanks for posting in #1088161997662724167.
Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets.

    - Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.)
    - Use [search.convex.dev](https://search.convex.dev) to search Docs, Stack, and Discord all at once.
    - Additionally, you can post your questions in the Convex Community's #1228095053885476985 channel to receive a response from AI.
    - Avoid tagging staff unless specifically instructed.

    Thank you!
ashen shuttle
#

Digging a bit deeper, it seems that on the page:
export const dynamic = 'force-static';

is what triggers the issue.

unique thunder
#

since that means no cookies, there's no way you could remain logged in

#

but if we're going to get questions / GitHub issues about it we should mention it in a Next.js guide or docs

#

Can I ask @ashen shuttle why you used export const dynamic = 'force-static', is there a tutorial you were following or a guide that recommended it?

ashen shuttle
#

I want to generate a static page while streaming server components. I'm also testing PPR. 🙂

unique thunder
#

Do you want to use auth on that static page?

unique thunder
#

If you could write up what you were trying to do or show a code sample in a Convex Auth GitHub issue that would be helpful

ashen shuttle
#

I'll definitely get to it this weekend. Thank you for your prompt response!

ashen shuttle