Skip to content

Commit

Permalink
update nextjs docs
Browse files Browse the repository at this point in the history
  • Loading branch information
pilcrowonpaper committed Oct 8, 2024
1 parent 4d9d27e commit 33a63fd
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pages/sessions/cookies/nextjs.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ export function deleteSessionTokenCookie(): void {
}
```

Since we can't extend set cookies insides server components due to a limitation with React, we recommend continuously extending the cookie expiration inside middleware. However, this comes with its own issue. Next.js revalidates the server component when a server action response sets a cookie directly with `cookies()` or indirectly with `NextResponse.cookies` via middleware. This can be solved by using `NextResponse.cookies`. But, we also can't detect if a new cookie was set inside server actions or route handlers from middleware. This becomes an issue if we need to assign a new session inside server actions (e.g. after updating the password) as the middleware cookie will override it. As such, we'll only extend the cookie expiration on GET requests.
Since we can't extend set cookies insides server components due to a limitation with React, we recommend continuously extending the cookie expiration inside middleware. However, this comes with its own issue. We can't detect if a new cookie was set inside server actions or route handlers from middleware. This becomes an issue if we need to assign a new session inside server actions (e.g. after updating the password) as the middleware cookie will override it. As such, we'll only extend the cookie expiration on GET requests.

> While Lucia v3 recommended setup extended session cookie lifetime, it did not avoid the revalidation issue.
```ts
// middleware.ts
Expand Down

0 comments on commit 33a63fd

Please sign in to comment.