}
-
-
+
+ }
+ title="Auth + charge"
+ description="Neither button needs you signed in: the SDK walks you through sign-in, adding a card and the charge."
+ />
+
- You're already signed in! Sign out to test this.
-
-
-
-
- `}
- >
-
-
-
-
-
- You're already signed in! Sign out to test this.
-
-
-
-
+ >
+
+
+
+
+ {SIGNED_IN_HINT}
+
+
+
+
`}
>
-
+
+
+
-
- Sign in to see the user button
-
+ Sign in to see the user button.`}
+ description="The signed-in user as a card."
+ code={``}
>
-
- Sign in to see your profile
-
+ Sign in to see your profile.
-
-
- {/* Control Components */}
-
-
-
+
+
+
+
+
+
You can see this!
`}
- >
-
-
-
-
- ✓ You're signed in, so you can see this!
-
-
-
-
-
-
- You're not signed in. The SignedIn component won't show.
-
-
-
-
-
-
-
+ >
+
+ }>
+ You're signed in, so you can see this.
+
+
+
+ }>You're signed out, so SignedIn renders nothing.
+
+
+
+
`}
- >
-
-
-
-
- ✓ You're signed out, so you can see this!
-
-
-
-
-
-
-
- You're signed in. The SignedOut component won't show.
-
-
-
+ >
+
+
+ }>
+ You're signed out, so you can see this.
+
+
-
-
- }
->
+
+
+ }>You're signed in, so SignedOut renders nothing.
+
+
+
+ }>
`}
- >
-
-
- See the protected page for a live example
-
-
-
-
- `}
- >
-
-
- You're signed in, so it won't redirect
-
-
-
-
- ⚠️ Disabled in this example to prevent redirect loop
-
-
-
-
-
-
- {/* Hooks */}
-
-
-
+ }>
+ See the{' '}
+
+ protected page
+ {' '}
+ for a live example.
+
+
+
+ `}
+ >
+
+ You're signed in, so it won't redirect.
+
+
+ }>
+ Disabled on this page to avoid a redirect loop.
+
+
+
+
+ {[
+ { href: '/examples', icon: LayoutGrid, title: 'Components', text: 'Every component and hook, live.' },
+ { href: '/protected', icon: ShieldCheck, title: 'Protected page', text: 'Gate a route with .' },
+ { href: '/api-demo', icon: Terminal, title: 'API demo', text: 'Call Hypery with your token.' },
+ { href: '/checkout', icon: CreditCard, title: 'Checkout', text: 'Buy and top up in one click.' },
+ ].map(({ href, icon: Icon, title, text }) => (
+
+
+
+ {title}
+
-
-
+
{text}
+
+ ))}
-
+
+
This page, in code
+
+
+
+ >
+ );
+}`}
+ />
+
);
}
diff --git a/auth-demo/app/protected/page.tsx b/auth-demo/app/protected/page.tsx
index 3835beb..345bf9b 100644
--- a/auth-demo/app/protected/page.tsx
+++ b/auth-demo/app/protected/page.tsx
@@ -1,11 +1,12 @@
'use client';
import { Protect, useUser } from '@hyperyai/sdk';
-import Link from 'next/link';
+import { CircleCheck, Info, ShieldCheck } from 'lucide-react';
+import { BackLink, C, Card, CodeBlock, Note, Page, PageHeader, Spinner } from '@/components/ui';
export default function ProtectedPage() {
return (
-
}>
+
}>
);
@@ -15,96 +16,37 @@ function ProtectedContent() {
const { user } = useUser();
return (
-
-
-
-
- Back to Home
-
-
-
-
-
-
-
-
Protected Page
-
-
-
-
-
- ✓ Access Granted
-
-
- You can see this page because you're authenticated. This is protected by the {``} component.
-
-
-
-
-
Your User Data:
-
-
{JSON.stringify(user, null, 2)}
+
+
+ }
+ title="Protected page"
+ description={<>Only signed-in visitors see this. It is wrapped in {''}.>}
+ />
+
+ } title="Access granted">
+ You can see this page because you're authenticated.
+
+
+
+
How protection works
+
+ {[
+ ['', 'Wraps content that requires authentication'],
+ ['fallback', 'Shown while the session is checked'],
+ ['redirect', 'Signed-out visitors are sent to sign in'],
+ ].map(([k, v]) => (
+
+
{k}
+
{v}
-
-
-
-
How Protection Works:
-
-
- {``}
-
Wraps content that requires authentication
-
-
- fallback
-
Shows loading state while checking auth
-
-
- redirect
-
Automatically redirects to login if not authenticated
-
-
-
-
-
-
Try it:
-
- Sign out from the user menu, then try visiting this page directly. You'll be automatically redirected to sign in!
-
-
- http://localhost:3003/protected
-
-
-
-
+ ))}
+
+
+ } title="Try it">
+ Sign out from the user menu, then open /protected directly: you'll be sent to sign in.
+