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)
57 lines
1.2 KiB
TypeScript
57 lines
1.2 KiB
TypeScript
import { auth, signIn, signOut, update } from "auth"
|
|
import Footer from "components/footer"
|
|
import { Header } from "components/header"
|
|
import styles from "components/header.module.css"
|
|
import "./styles.css"
|
|
|
|
export default function RootLayout(props: { children: React.ReactNode }) {
|
|
return (
|
|
<html>
|
|
<body>
|
|
<AppHeader />
|
|
<main>{props.children}</main>
|
|
<div>
|
|
<form
|
|
action={async () => {
|
|
"use server"
|
|
update({ user: { name: "New Name" } })
|
|
}}
|
|
>
|
|
<button>Update name</button>
|
|
</form>
|
|
</div>
|
|
<Footer />
|
|
</body>
|
|
</html>
|
|
)
|
|
}
|
|
|
|
export async function AppHeader() {
|
|
const session = await auth()
|
|
return (
|
|
<Header
|
|
session={session}
|
|
signIn={
|
|
<form
|
|
action={async () => {
|
|
"use server"
|
|
await signIn("github")
|
|
}}
|
|
>
|
|
<button className={styles.buttonPrimary}>Sign in</button>
|
|
</form>
|
|
}
|
|
signOut={
|
|
<form
|
|
action={async () => {
|
|
"use server"
|
|
await signOut()
|
|
}}
|
|
>
|
|
<button className={styles.button}>Sign out</button>
|
|
</form>
|
|
}
|
|
/>
|
|
)
|
|
}
|