Accounts Quick Start
Accounts Quick Start
Section titled “Accounts Quick Start”When users sign in to your Varity app, they automatically get a fully capable account. No extra setup needed.
Prerequisites
Section titled “Prerequisites”- A Varity project with authentication set up (Auth Quick Start)
- Node.js 18 or later
What Happens When Users Sign In
Section titled “What Happens When Users Sign In”When a user logs in via PrivyStack, Varity automatically:
- Authenticates the user via email or social login
- Creates a secure account linked to their identity
- Enables all app capabilities (payments, storage, etc.)
- Sets up session handling
You don’t need to configure anything extra — PrivyStack handles everything.
Checking Account Status
Section titled “Checking Account Status”Use the usePrivy hook to check if a user is signed in and access their account info:
import { usePrivy } from '@varity-labs/ui-kit';
function AccountStatus() { const { authenticated, user, ready } = usePrivy();
if (!ready) return <p>Loading...</p>; if (!authenticated) return <p>Not signed in</p>;
return ( <div> <p>Signed in as: {user?.email?.address || 'User'}</p> <p>Account active</p> </div> );}Protecting Routes
Section titled “Protecting Routes”Show content only to signed-in users:
import { PrivyProtectedRoute } from '@varity-labs/ui-kit';
function App() { return ( <PrivyProtectedRoute> <Dashboard /> </PrivyProtectedRoute> );}You can also check authentication status programmatically:
import { usePrivy } from '@varity-labs/ui-kit';
function ConditionalContent() { const { authenticated, login } = usePrivy();
if (!authenticated) { return <button onClick={login}>Sign in to continue</button>; }
return <p>Welcome back! Your account is ready.</p>;}Advanced: Account Infrastructure
Behind the scenes, Varity handles all account infrastructure automatically. When a user signs in, a secure account is created and configured with all capabilities enabled by default — including sponsored operations so users never see unexpected fees.
No configuration is required. Advanced users who need lower-level access to account features can see Session Keys for details.
Available Hooks and Components
Section titled “Available Hooks and Components”All of the following are exported from @varity-labs/ui-kit:
| Export | Type | Description |
|---|---|---|
PrivyStack | Component | Wraps your app with authentication |
VarityPrivyProvider | Component | Lower-level auth provider |
PrivyLoginButton | Component | Pre-built sign-in button |
PrivyUserProfile | Component | Displays user profile info |
PrivyProtectedRoute | Component | Protects routes from unauthenticated access |
PrivyReadyGate | Component | Renders children only after auth initializes |
usePrivy | Hook | Access auth state, user data, login/logout |
useWallets | Hook | Access connected accounts |
useLogin | Hook | Programmatic login |
useLogout | Hook | Programmatic logout |
Next steps
Section titled “Next steps”- Authentication Quick Start — Set up user login
- Create Account — Account creation details
- Session Keys — Advanced operation patterns