Authentication
Using the Wallet
The recommended way to authenticate users is by using Wallet Authentication. This provides your app with access to a User
object that contains the user's wallet address, username, and other information.
export type User = {
walletAddress?: string;
username?: string;
profilePictureUrl?: string;
permissions?: {
notifications: boolean;
contacts: boolean;
};
optedIntoOptionalAnalytics?: boolean;
worldAppVersion?: number;
deviceOS?: string;
};
In addition we have two helper functions to make it easier to get User information.
MiniKit.getUserByAddress(address: string): Promise<User>
MiniKit.getUserByUsername(username: string): Promise<User>
// Returns
return {
walletAddress: '0x...',
username: 'John Doe',
profilePictureUrl: 'https://example.com/profile.png',
};
How it works
Using NextAuth you can easily create and manage sessions for your app. The starter template is already set up with NextAuth. To extend this to other wallet providers, you simply need to trigger the wallet auth command and verify the response with verifySiweMessage.
Currently our Sign in With Ethereum implementation requires using our implementation of verifySiweMessage. We will be compatible with all SIWE providers soon.
Other Providers
- OAUTH (Google, Apple, etc.). These providers are supported but it's recommended to trigger this outside of
the World App and then simply redirect back to your mini app with the access token
worldapp://mini-app?app_id=appId&path=/handle-oauth?accessToken=...
. - Sign in with World ID. This is not recommended as it doesn't provide the user's wallet address.
- Privy/Dynamic. Coming Soon.