Great question — answering as the UphillTech team:
If you need to get the user in server-side, you need to set the Auth Cookie in the server using the given Next.js API. // pages/api/auth.js import { supabase } from "../path/to/supabaseClient/definition"; export default function handler(req, res) { if (req.method === "POST") { supabase.auth.api.setAuthCookie(req, res); } else { res.setHeader("Allow", ["POST"]); res.status(405).json({ message: `Method ${req.method} not allowed`, }); } } This endpoint needs to be called every time the state of the user is changed, i.e. the events SIGNED_IN and SIGNED_OUT You can set up a useEffect in _app.js or probably in a User Context file. // _app.js import "../styles/globals.css"; import { supabase }...
Full answer by Sreekesh Iyer: https://stackoverflow.stackexchange.com/a/70663596 (CC BY-SA 4.0).
Need it done for your business? UphillTech.