You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This function can then be used in server components and form actions to get the current session and user.
251
+
This function can then be used in server components and form actions to get the current session and user.
252
252
253
253
```tsx
254
254
import { redirect } from"next/navigation";
@@ -263,6 +263,8 @@ export default async function Page() {
263
263
}
264
264
```
265
265
266
+
> 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.
267
+
266
268
## Sign out
267
269
268
270
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()`.
Copy file name to clipboardexpand all lines: docs/pages/tutorials/username-and-password/nextjs-app.md
+2
Original file line number
Diff line number
Diff line change
@@ -317,6 +317,8 @@ export default async function Page() {
317
317
}
318
318
```
319
319
320
+
> 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.
321
+
320
322
## Sign out
321
323
322
324
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()`.
0 commit comments