MCPcopy Index your code
hub / github.com/nextauthjs/next-auth-example / UpdateForm

Function UpdateForm

components/client-example.tsx:10–33  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

8import CustomLink from "./custom-link"
9
10const UpdateForm = () => {
11 const { data: session, update } = useSession()
12 const [name, setName] = useState(`New ${session?.user?.name}`)
13
14 if (!session?.user) return null
15 return (
16 <>
17 <h2 className="text-xl font-bold">Updating the session client-side</h2>
18 <div className="flex w-full max-w-sm items-center space-x-2">
19 <Input
20 type="text"
21 placeholder="New name"
22 value={name}
23 onChange={(e) => {
24 setName(e.target.value)
25 }}
26 />
27 <Button onClick={() => update({ user: { name } })} type="submit">
28 Update
29 </Button>
30 </div>
31 </>
32 )
33}
34
35export default function ClientExample() {
36 const { data: session, status } = useSession()

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected