Using Nextjs 13 Route Middleware in Client Side
Unanswered
Ojos Azules posted this in #help-forum
Ojos AzulesOP
I am trying to use NextJS 13 Route Middleware to check for Metamask authenticated Users using Wagmi Package. But since wagmi works on client side. I am unable to achieve that in middleware. I tried using
"use client" on the top of the middleware.ts. But it doesn't seem to work12 Replies
I guess you have to wrap your app using a wrapper with use client and check that in there
Ojos AzulesOP
everything will become client component then
🥲
that's how web3 works. middleware is supposed to run on Edge Runtime, which is not related to ReactJS, just a light weight Node.js with no cold start time.
@Ojos Azules everything will become client component then
create a client component which returns null and in useEffect of that do whatever you want with wagmi
@Ojos Azules I am trying to use NextJS 13 Route Middleware to check for Metamask authenticated Users using Wagmi Package. But since wagmi works on client side. I am unable to achieve that in middleware. I tried using `"use client"` on the top of the `middleware.ts`. But it doesn't seem to work
you can do it via siwe and next-auth, or you can do what phantom said and have it set a cookie or redirect etc
Ojos AzulesOP
thanks people
i'll try these
or NFT token
Ojos AzulesOP
would have been good if we could've used routes middleware as client component 🥲
react hooks are easier
Ojos AzulesOP
ðŸ‘