A minimal demo app showcasing the @hyperyai/sdk authentication library.
<HyperyProvider>- Main auth provider wrapping the app<SignIn />- Pre-built sign-in button<UserButton />- Avatar with dropdown menu<SignedIn />- Conditional rendering for authenticated users<SignedOut />- Conditional rendering for unauthenticated users<Protect />- Route protection wrapper
useUser()- Access current user datauseHyperyAuth()- Full auth context with methodsgetAccessToken()- Get valid access token for API requests
- Home (
/) - Landing page with sign-in - Protected (
/protected) - Demo of protected route - API Demo (
/api-demo) - Interactive API request demo - Modals (
/modals) - Runnable source:app/modals/page.tsx— realfetchto/api/v1/chat/completions,RestrictionModalon structured errors,AuthModaltrigger - Examples (
/examples) - Component gallery (AuthModal, forms, hooks) - Callback (
/callback) - OAuth callback handler
npm installCreate a .env.local file:
NEXT_PUBLIC_OAUTH_CLIENT_ID=your_client_id_here
NEXT_PUBLIC_REDIRECT_URI=http://localhost:3003/callback
NEXT_PUBLIC_AUTH_URL=http://localhost:3001Get your Client ID:
- Go to http://localhost:3001/settings/your-team/apps
- Create a new app or use an existing one
- Copy the Client ID
- Add
http://localhost:3003/callbackto the redirect URIs
npm run devVisit http://localhost:3003
- Click "Sign in with Hypery"
- You'll be redirected to http://localhost:3001
- Authorize the application
- You'll be redirected back and authenticated
- While signed in, visit http://localhost:3003/protected
- You'll see protected content
- Sign out, then try visiting the same URL
- You'll be automatically redirected to sign in
- Navigate to http://localhost:3003/api-demo
- Click "Get Access Token" to see your token
- Click "Make Authenticated Request" to call the API
- See the response from the Hypery API
- Sign in, then open http://localhost:3003/modals
- Click Call /api/v1/chat/completions — on success you’ll see the assistant text and raw JSON
- If the hub returns a structured billing/limit error,
RestrictionModalopens (same pattern as JustMakeIt) - Use Open AuthModal to exercise the sign-in dialog component
- Source to copy from:
auth-demo/app/modals/page.tsx
- Tokens are automatically refreshed before expiration
- No manual token handling required
- Secure storage in localStorage
- PKCE (Proof Key for Code Exchange) for security
- State parameter for CSRF protection
- Automatic callback handling
- React hooks for easy integration
- Pre-built components for rapid development
- TypeScript support out of the box
// app/layout.tsx
import { HyperyProvider } from '@hyperyai/sdk';
export default function RootLayout({ children }) {
return (
<HyperyProvider config={{
clientId: process.env.NEXT_PUBLIC_OAUTH_CLIENT_ID!,
redirectUri: process.env.NEXT_PUBLIC_REDIRECT_URI!,
gatewayUrl: process.env.NEXT_PUBLIC_AUTH_URL!,
scopes: ['read', 'write', 'ai:chat'],
}}>
{children}
</HyperyProvider>
);
}import { SignedIn, SignedOut, SignIn, UserButton } from '@hyperyai/sdk';
function Header() {
return (
<>
<SignedIn>
<UserButton showUserInfo />
</SignedIn>
<SignedOut>
<SignIn />
</SignedOut>
</>
);
}import { Protect } from '@hyperyai/sdk';
export default function ProtectedPage() {
return (
<Protect>
<YourProtectedContent />
</Protect>
);
}import { useHyperyAuth } from '@hyperyai/sdk';
function MyComponent() {
const { getAccessToken } = useHyperyAuth();
const fetchData = async () => {
const token = await getAccessToken();
const response = await fetch('/api/endpoint', {
headers: {
Authorization: `Bearer ${token}`,
},
});
return response.json();
};
}auth-demo/
├── app/
│ ├── api-demo/
│ │ └── page.tsx # API demo page
│ ├── callback/
│ │ └── page.tsx # OAuth callback handler
│ ├── protected/
│ │ └── page.tsx # Protected route example
│ ├── layout.tsx # Root layout with provider
│ ├── page.tsx # Home page
│ └── globals.css
├── package.json
├── ENV.md # Environment setup guide
└── README.md
- Package Documentation:
/packages/hypery-sdk/README.md - More Examples:
/packages/hypery-sdk/EXAMPLES.md - Hypery Docs: http://localhost:3001/docs
MIT