-
Notifications
You must be signed in to change notification settings - Fork 190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add SIWE support for Next.js App Router #318
base: main
Are you sure you want to change the base?
Conversation
@alex-grover is attempting to deploy a commit to the LFE Team on Vercel. A member of the Team first needs to authorize it. |
07dcc9a
to
673a3da
Compare
looks like I also stumbled upon the way that https://next-auth.js.org/configuration/initialization#simple-initialization |
sounds awesome! thank you @alex-grover 🙌 |
hey guys, any updade on this topic? I'd love to use connectkit but current version just doesn't work for nextjs with app approach, unless there is some workaround i can do in my code? |
I don't have a ton of bandwidth to finish this out at the moment unfortunately, but you can find 2 examples of how to implement SIWE in the app router here: #316 (comment) |
This is a draft with some outstanding items remaining to get it ready for merge, but I'd like to get some feedback to make sure this approach works for you!
I aimed to keep the code as close to the original pages dir implementation as possible. The main changes necessary were:
app
dir format, which means slightly different exports and route handlers with the shape(req: NextRequest) => Promise<NextResponse>
Session
class that replaces some of the functionality ofiron-session
(getIronSession
) that hasn't been updated for theapp
dir yetConsiderations
This implementation adds a second export to the existing
connectkit-next-siwe
package,configureServerSideSIWEAppRouter
(open to feedback on naming). I went with this route because the client code is the same between pages and app dir, and a simpler package publishing setup seems nice vs. having a second package just for the app dir.However, this has a couple implications:
GET
andPOST
methods rather than one default exportThese seem like okay trade-offs to me (next 13 has been out for a while now and the API difference is small), but the version bump is a breaking change.
Remaining TODOs
iron-session
, which does more error checking and sets some config defaults. We probably want a matching implementation, so users don't have to manually set things like session max-age in the app dir.