kinde-oss / kinde-auth-nextjs

Kinde NextJS SDK - authentication for server rendered apps
https://docs.kinde.com/developer-tools/sdks/backend/nextjs-sdk/
MIT License
157 stars 24 forks source link

Feature request: Refresh Active Sessions Automatically #237

Open paulbeh opened 2 weeks ago

paulbeh commented 2 weeks ago

Prerequisites

What is the problem you’re trying to solve?

Users are currently logged out one day after signing in, due to token expiry. This experience interrupts user workflows and creates inconvenience for regular users.

What solution would you like to see?

Implement a middleware function to monitor tokens approaching expiry and proactively refresh them. Ideally, the middleware would invoke refreshTokens before tokens expire. However, calling refreshTokens in the current middleware setup is not feasible, as it depends on cookies() from next/headers, which is inaccessible in the middleware context.