"use client" import { useSession } from "next-auth/react" import { Button } from "./ui/button" import { Input } from "./ui/input" import { useState } from "react" import SessionData from "./session-data" import CustomLink from "./custom-link" const UpdateForm = () => { const { data: session, update } = useSession() const [name, setName] = useState(session?.user.name ?? "") if (!session) return null return ( <>

Updating the session

{ if (session) { const newSession = await update({ ...session, user: { ...session.user, name }, }) console.log({ newSession }) } }} className="flex items-center w-full max-w-sm space-x-2" > { setName(e.target.value) }} />
) } export default function ClientExample() { const { data: session, status } = useSession() return (

Client Side Rendering Usage

This page fetches session data client side using the{" "} useSession {" "} React Hook.

It needs the{" "} 'use client' {" "} directive at the top of the file to enable client side rendering, and the{" "} SessionProvider {" "} component in{" "} client-example/page.tsx {" "} to provide the session data.

{status === "loading" ? (
Loading...
) : ( )}
) }