Next.js Discord

Discord Forum

Using Nextjs 13 Route Middleware in Client Side

Unanswered
Ojos Azules posted this in #help-forum
Open in Discord
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 work

12 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 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
👍