Skip to content

Social Login

Varity Team Core Contributors Updated March 2026

Let users sign in with accounts they already have. No new passwords, no email verification—just one click.

ProviderLogin Method
Googlegoogle
Twitter/Xtwitter
Discorddiscord
GitHubgithub
Appleapple
  1. Configure login methods

    app/layout.tsx
    import { PrivyStack } from '@varity-labs/ui-kit';
    export default function RootLayout({ children }) {
    return (
    <html>
    <body>
    <PrivyStack
    loginMethods={['email', 'google', 'twitter', 'discord']}
    >
    {children}
    </PrivyStack>
    </body>
    </html>
    );
    }
  2. Add the login button

    The PrivyLoginButton automatically shows all configured providers:

    components/LoginButton.tsx
    import { PrivyLoginButton } from '@varity-labs/ui-kit';
    export function LoginButton() {
    return <PrivyLoginButton />;
    }

Users will see a modal with options for email and all configured social providers.

After social login, user data is available through usePrivy:

components/UserInfo.tsx
import { usePrivy } from '@varity-labs/ui-kit';
export function UserInfo() {
const { user } = usePrivy();
if (!user) return null;
// Email from social provider
const email = user.email?.address;
// Google-specific data
const google = user.google;
if (google) {
console.log('Google email:', google.email);
console.log('Google name:', google.name);
}
// Twitter-specific data
const twitter = user.twitter;
if (twitter) {
console.log('Twitter handle:', twitter.username);
}
// Discord-specific data
const discord = user.discord;
if (discord) {
console.log('Discord username:', discord.username);
}
return (
<div>
<p>Email: {email}</p>
{twitter && <p>Twitter: @{twitter.username}</p>}
</div>
);
}

Customize the appearance of the login modal:

app/layout.tsx
<PrivyStack
loginMethods={['email', 'google', 'twitter']}
appearance={{
theme: 'light',
accentColor: '#4F46E5',
logo: '/logo.png'
}}
>
{children}
</PrivyStack>
PropertyTypeDescription
theme'light' or 'dark'Color theme
accentColorHex colorPrimary brand color
logoURL stringYour app logo

To disable email login and only allow social providers:

app/layout.tsx
<PrivyStack
loginMethods={['google', 'twitter', 'discord']}
>
{children}
</PrivyStack>

Pick providers your users actually use:

App TypeRecommended Providers
Consumer appGoogle, Apple
Developer toolsGitHub, Google
Gaming/CommunityDiscord, Twitter
components/LoginWithErrorHandling.tsx
import { PrivyLoginButton } from '@varity-labs/ui-kit';
import { toast } from 'react-hot-toast';
export function LoginWithErrorHandling() {
return (
<PrivyLoginButton
onSuccess={(user) => {
toast.success(`Welcome, ${user.email?.address || 'User'}!`);
}}
onError={(error) => {
if (error.message.includes('popup_closed')) {
toast.error('Login cancelled');
} else {
toast.error('Login failed. Please try again.');
}
}}
/>
);
}