Next js metamask server side/ Api integration

Hi, i have a question. this question is not specific to next js but has anyone tried interacting with metamask or other injected providers from the pages/api folder. i have not seen any guides on how to do it. I am not sure how to go about it since servers and api side donโ€™t have access to the browsers window object. is the only option to directly interact with metamask within the components.
i am just trying to have my execution and logic functions implemented on the server side, and then sent back to metamask(or any other injected provider) for users signature and submission to the blockchain.

Common way is to use useEffect to force the window code to run in the browser. Yes you will have to pass info between your components and serverside in some way.

Hi, i just saw this. do you mind sharing any available resources. i will like to look into it more

This tutorial may be useful: Web3 Authentication With React, NextJS and Moralis - YouTube

Interacting with Next.jsโ€™s API is more a general fundamental with the framework, you can check out their docs. If you want to do something specific, then you can outline that here.