Quick Start

Responses

World App will return responses to your mini app based on the command sent. You can define custom logic to handle these responses with MiniKit.

You can choose to mount these responses globally, but we recommend adding them only to the pages where they're triggered and cleaning them up after.

Example Response

Listening for a response from the Verify command in your mini app.

import { MiniKit, ResponseEvent } from '@worldcoin/minikit-js'
// ...
useEffect(() => {
	if (!MiniKit.isInstalled()) {
		return
	}

	MiniKit.subscribe(ResponseEvent.MiniAppVerifyAction, async verifyResponse => {
		if (payload.status === 'error') {
			return console.log('Error payload', payload)
		}

		// Verify the proof in the backend
		const verifyResponse = await fetch('/api/verify', {
			method: 'POST',
			headers: {
				'Content-Type': 'application/json',
			},
			body: JSON.stringify({
				payload: verifyResponse,
				action: verifyResponse.action,
			}),
		})
	})

	return () => {
		// Clean up on unmount
		MiniKit.unsubscribe(ResponseEvent.MiniAppVerifyAction)
	}
}, [])