Skip to content

Commit

Permalink
docs: add note about not using validateRequest() in layout.tsx on app… (
Browse files Browse the repository at this point in the history
  • Loading branch information
sommeeeer authored Oct 20, 2024
1 parent fb23b4d commit 85eb465
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion docs/pages/tutorials/github-oauth/nextjs-app.md
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ export const validateRequest = cache(
);
```

This function can then be used in server components and form actions to get the current session and user.
This function can then be used in server components and form actions to get the current session and user.

```tsx
import { redirect } from "next/navigation";
Expand All @@ -263,6 +263,8 @@ export default async function Page() {
}
```

> Note: This code is not suitable for use in `layout.tsx` files. Layouts do not re-render on page transitions, so the authentication check won't run for each route change.
## Sign out

Sign out users by invalidating their session with `Lucia.invalidateSession()`. Make sure to remove their session cookie by setting a blank session cookie created with `Lucia.createBlankSessionCookie()`.
Expand Down
2 changes: 2 additions & 0 deletions docs/pages/tutorials/username-and-password/nextjs-app.md
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,8 @@ export default async function Page() {
}
```

> Note: This code is not suitable for use in `layout.tsx` files. Layouts do not re-render on page transitions, so the authentication check won't run for each route change.
## Sign out

Sign out users by invalidating their session with `Lucia.invalidateSession()`. Make sure to remove their session cookie by setting a blank session cookie created with `Lucia.createBlankSessionCookie()`.
Expand Down

0 comments on commit 85eb465

Please sign in to comment.