Profile (fetched from API)
+User
+{JSON.stringify(user, null, 2)}
+ diff --git a/app/api/profile/route.ts b/app/api/profile/route.ts
new file mode 100644
index 0000000..d2726ad
--- /dev/null
+++ b/app/api/profile/route.ts
@@ -0,0 +1,11 @@
+import { NextResponse } from 'next/server';
+
+import { getSession, withApiAuthRequired } from '@auth0/nextjs-auth0';
+
+const GET = withApiAuthRequired(async () => {
+ const session = await getSession();
+
+ return NextResponse.json(session?.user);
+});
+
+export { GET };
diff --git a/app/profile/page.tsx b/app/profile/page.tsx
new file mode 100644
index 0000000..90cadc6
--- /dev/null
+++ b/app/profile/page.tsx
@@ -0,0 +1,23 @@
+'use client';
+
+import { withPageAuthRequired } from '@auth0/nextjs-auth0/client';
+import { useEffect, useState } from 'react';
+
+export default withPageAuthRequired(function Profile() {
+ const [user, setUser] = useState();
+
+ useEffect(() => {
+ (async () => {
+ const res = await fetch(`${window.location.origin}/api/profile`);
+ setUser(await res.json());
+ })();
+ }, []);
+
+ return (
+ Profile (fetched from API)
+ User
+ {JSON.stringify(user, null, 2)}
+
{user.email}
-