mirror of
https://github.com/SrIzan10/next-auth.git
synced 2026-05-01 10:55:20 +00:00
Next.js 13.4 [is out](https://nextjs.org/blog/next-13-4). For discussing project-related issues, please use https://github.com/nextauthjs/next-auth/discussions/8487 The new version of NextAuth.js is based on `@auth/core`. If you want to test it out, you can do so already, installing `next-auth@experimental`: - **Documentation**: https://authjs.dev/reference/nextjs - **Migration guide**: https://authjs.dev/guides/upgrade-to-v5 BREAKING CHANGE: Follow the [migration guide](https://authjs.dev/guides/upgrade-to-v5)
32 lines
999 B
TypeScript
32 lines
999 B
TypeScript
import type { Session } from "next-auth"
|
|
|
|
export default function SessionData({ session }: { session: Session | null }) {
|
|
if (session) {
|
|
return (
|
|
<div className="w-full space-y-2 overflow-auto">
|
|
<h2 className="text-xl font-bold">Current Session Data</h2>
|
|
{Object.keys(session.user).length > 3 ? (
|
|
<p>
|
|
In this example, the whole session object is passed to the page,
|
|
including the raw user object. Our recommendation is to{" "}
|
|
<em>only pass the necessary fields</em> to the page, as the raw user
|
|
object may contain sensitive information.
|
|
</p>
|
|
) : (
|
|
<p>
|
|
In this example, only some fields in the user object is passed to
|
|
the page to avoid exposing sensitive information.
|
|
</p>
|
|
)}
|
|
<pre>{JSON.stringify(session, null, 2)}</pre>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
return (
|
|
<p>
|
|
No session data, please <em>Sign In</em> first.
|
|
</p>
|
|
)
|
|
}
|