Immutable solution version
Next.js SSR: intermittent JWT token expired errors
Complete solution
Shows how to fix next.js SSR: intermittent JWT token expired errors. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
When it applies
Not specified by the original author.
Instructions
TL;DR
Upgrade your Nhost JS SDKs (@nhost/nextjs, @nhost/react) to the release containing the fix. Intermittent 'JWT token expired' errors in Next.js SSR (both client and server, with getNhostSession) were an SDK bug in the token refresh path, already fixed upstream.
Steps
- Intermittent 'JWT token expired' errors in Next.js SSR (both client and server, with getNhostSession) were an SDK bug in the token refresh path, already fixed upstream. Upgrade your Nhost JS SDKs (@nhost/nextjs, @nhost/react) to the release containing the fix. If you're pinned to an old version and see random auth expiry under SSR, update first before debugging your session code.
- Source: https://github.com/nhost/nhost/issues/2348 (Nhost)
When to use
Use this skill when you run into "Next.js SSR: intermittent JWT token expired errors".
When not to use
If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.
Versions
No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.
Why this happens
The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.
Sources
- https://github.com/nhost/nhost/issues/2348
Evidence
In gh:nhost/nhost#2348, the issue was: I'm investigating integrating next + nhost with SSR enabled (pages router). Setup: [NhostProvider] + [NhostApolloProvider] + getNhostSession from nhost/nextjs. In general it works really well. But sometimes (and it's not clear when and why) I receive errors about JWT token being expired, both on client and server.. The verified answer: Intermittent 'JWT token expired' errors in Next.js SSR (both client and server, with getNhostSession) were an SDK bug in the token refresh path, already fixed upstream. Upgrade your Nhost JS SDKs (@nhost/nextjs, @nhost/react) to the release containing the fix. If you're pinned to an old version and see random auth expiry under SSR, update first before debugging your session code.. Issue URL: https://github.com/nhost/nhost/issues/2348
By @issueatlas · Version 2 · Exact version
Maintainer review
Checking maintainer review for this exact version…
A maintainer review records the library version checked. It does not assert that it is the latest upstream release. Reported outcomes are separate evidence.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_JN5O7j9l_4n52fGCY0Dclg" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Next.js SSR: intermittent JWT token expired errors <span>— Vectle</span></a>