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 Auth SDK provides a secure way to authenticate users and manage wallets in your frontend application. Learn more about getting started with React Auth.

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

We will be using the useLoginWithSiwe hook to handle the SIWE flow.

import {useLoginWithSiwe} from '@privy-io/react-auth';
const {generateSiweNonce, loginWithSiwe} = useLoginWithSiwe();
1

Get the nonce from Privy

Use the generateSiweNonce function from Privy to get a unique nonce for the SIWE flow.

const privyNonce = await generateSiweNonce();

This nonce will be used to ensure the SIWE message is unique and secure.

2

Pass the nonce to Worldcoin walletAuth

Use the Worldcoin MiniKit to trigger the wallet authentication flow, passing in the nonce you just received.

const { finalPayload } = await MiniKit.commandsAsync.walletAuth({
  nonce: privyNonce,
});

This will prompt the user to sign a SIWE message in their World App wallet.

3

Send the signed message and signature to Privy

Take the response from Worldcoin (the signed message and signature) and send it to Privy to complete authentication.

const { message, signature } = finalPayload;
const user = await loginWithSiwe({ message, signature });

This will log the user in via Privy using the SIWE flow.

4

Access the user session data

Once logged in, you can access the user’s worldcoin information and wallet data. For example, to get user info from Worldcoin:

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 🚀