WalletConnect / web3modal

A single Web3 provider solution for all Wallets

Home Page:https://web3modal.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[feature] Default SIWE Handlers

wslyvh opened this issue · comments

What problem does this new feature solve?

The documentation on SIWE is very limited and incomplete.
i.e. it's unclear from just the docs on how to set up SIWE and lacks a proper step-by-step guide.
https://docs.walletconnect.com/web3modal/nextjs/siwe/about

I also think it's unnecessary to copy/paste most of the documented functions as they could be provided out of the box by the W3M packages.

Describe the solution you'd like

I'd love to see a default (Next.js) SIWE implementation that can be referenced to reduce the amount of code/steps required to set up in my own codebase.

I think what's needed is and could be included in W3M:

  1. allow to create a SIWEClientConfig (to configure the API routes)
  2. allow to create a SIWEServerConfig (to configure iron-session, cookie name and password)
  3. the generic handler implementation

The handlers should include a default implementation for the interface as described on
https://docs.walletconnect.com/web3modal/nextjs/siwe/about#siwe-config-parameters

From an App perspective, you'd then only have to configure a client/server config and import the default W3M handler at a dynamic route (e.g. /api/siwe/[...route].ts)
https://nextjs.org/docs/pages/building-your-application/routing/dynamic-routes

ConnectKit has a great example, and I would love to see something similar in W3M
https://docs.family.co/connectkit/auth-with-nextjs#example