Skip to content

Commit

Permalink
Create page.md
Browse files Browse the repository at this point in the history
  • Loading branch information
BcnCarlos authored Jan 16, 2025
1 parent 08ab6ef commit 631cde7
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions articles/quickstart/webapp/nextjs/files/page.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
name: "src/app/page.tsx"
language: javascript
---

<!-- markdownlint-disable MD041 -->

```javascript
import { auth0 } from "@/lib/auth0";
import './globals.css';

export default async function Home() {
// Fetch the user session
const session = await auth0.getSession();

// If no session, show sign-up and login buttons
if (!session) {
return (
<main className="page">
<a href="/auth/login?screen_hint=signup">
<button className="white">Sign up</button>
</a>
<a href="/auth/login">
<button>Log in</button>
</a>
</main>
);
}

// If session exists, show a welcome message and logout button
return (
<main>
<h1>Welcome, {session.user.name}!</h1>
<p>
<a href="/auth/logout">
<button>Log out</button>
</a>
</p>
</main>
);
}
```

0 comments on commit 631cde7

Please sign in to comment.