Skip to main content
Convert an existing Next.js web app that uses viem to work as a World App mini app.

Ask an agent

Add this skill and ask your agent to convert your web app to a mini app using the steps outlined in this guide.

1. Install MiniKit

2. Disable SSR

MiniKit depends on window.WorldApp. SSR causes hydration mismatches that silently break event handlers.
src/app/page.tsx

3. Add MiniKitProvider

src/app/providers.tsx
Wrap children in your layout:
src/app/layout.tsx

4. Wallet Connection

Use getWorldAppProvider() inside World App, fall back to window.ethereum for browsers.
Under the hood, getWorldAppProvider() maps:
  • eth_requestAccountsMiniKit.walletAuth()
  • eth_sendTransactionMiniKit.sendTransaction()
  • eth_chainId0x1e0 (World Chain 480)
Existing writeContract / readContract calls work unchanged.

5. Bundle Approve + Contract Calls

World App resets approvals to 0 after each transaction. A separate approve() tx followed by transferFrom() in the next tx will fail. Bundle them in one call:
World App executes these atomically. On web, they execute sequentially — each requires a separate wallet confirmation and is not atomic.

6. Handle userOpHash Receipts

MiniKit returns a userOpHash, not a standard tx hash. Use useUserOperationReceipt from @worldcoin/minikit-react to poll for the receipt:

7. Whitelist Contracts and Tokens

In Developer Portal > Mini App > Permissions, add:
  • Permit2 Tokens — every ERC-20 your app transfers
  • Contract Entrypoints — every contract your app calls
Non-whitelisted contracts are blocked with invalid_contract.

Common Gotchas