Download next.js/examples/auth/app/page.tsx from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 814 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/examples/auth/app/page.tsx
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/next.js/examples/auth/app/page.tsx
-
curl -L -o page.tsx https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/examples/auth/app/page.tsx
814 Bytes
| import { auth, signIn, signOut } from "@/auth"; | |
| function SignIn() { | |
| return ( | |
| <form | |
| action={async () => { | |
| "use server"; | |
| await signIn("github"); | |
| }} | |
| > | |
| <p>You are not logged in</p> | |
| <button type="submit">Sign in with GitHub</button> | |
| </form> | |
| ); | |
| } | |
| function SignOut({ children }: { children: React.ReactNode }) { | |
| return ( | |
| <form | |
| action={async () => { | |
| "use server"; | |
| await signOut(); | |
| }} | |
| > | |
| <p>{children}</p> | |
| <button type="submit">Sign out</button> | |
| </form> | |
| ); | |
| } | |
| export default async function Page() { | |
| let session = await auth(); | |
| let user = session?.user?.email; | |
| return ( | |
| <section> | |
| <h1>Home</h1> | |
| <div>{user ? <SignOut>{`Welcome ${user}`}</SignOut> : <SignIn />}</div> | |
| </section> | |
| ); | |
| } | |