Skip to main content
Privy offers a seamless integration with Worldcoin Mini Apps. This guide will walk you through integrating Sign-In With Ethereum (SIWE) using Privy in a Worldcoin Mini App. With this setup, you can offer secure wallet authentication for your users—combining the power of World App’s native wallet with Privy’s flexible authentication and wallet infrastructure.

Resources

Configure your Worldcoin developer portal

Create a Worldcoin developer account and mini app, learn more here.

Get set up with Privy

If you haven’t set up Privy yet, follow our React quickstart guide to get your app ID and configure your app.
Privy’s React SDK provides a secure way to authenticate users and manage wallets in your frontend application. Learn more about getting started with React.

Set up with Worldcoin Mini App

1

Create your mini app using the quickstart

Scaffold a new Worldcoin Mini App using the official template:
npx @worldcoin/create-mini-app@latest my-mini-app
Follow the prompts in the README to set up your app. Use the env variables from your Worldcoin developer portal to configure your app.
2

Explore the starter repo structure

Your new app will have a file at src/components/AuthButton/index.tsx—this is where you’ll add Privy SIWE support.

SIWE into mini app with Privy

Use Privy’s useLoginWithSiwe hook to authenticate users with their World App wallet. The SIWE flow works as follows:
1

Get a nonce from Privy

Generate a unique nonce using generateSiweNonce() to ensure the SIWE message is secure.
2

Request wallet signature

Pass the nonce to World MiniKit’s walletAuth() command, which prompts the user to sign a SIWE message in their World App wallet.
3

Complete authentication

Send the signed message and signature back to Privy using loginWithSiwe() to complete the authentication flow.

Implementation

Use Privy’s useLoginWithSiwe hook to authenticate users via their World wallet:
import {useLoginWithSiwe} from '@privy-io/react-auth';
import MiniKit from '@worldcoin/minikit-js';

const {generateSiweNonce, loginWithSiwe} = useLoginWithSiwe();

const handleLogin = async () => {
  // Get nonce from Privy
  const privyNonce = await generateSiweNonce();

  // Request signature from World wallet
  const {finalPayload} = await MiniKit.commandsAsync.walletAuth({
    nonce: privyNonce
  });

  // Log in with Privy
  await loginWithSiwe({
    message: finalPayload.message,
    signature: finalPayload.signature
  });
};

Access user data

Once logged in, you can access the user’s World information and wallet data:
const userInfo = await MiniKit.getUserByAddress(user.wallet.address);
Your Worldcoin Mini App now supports SIWE authentication with Privy and World App! Enjoy seamless, secure onboarding for your users 🚀