nextjs auth wihtout helpers

i am trying to implement as simple nextjs auth with supabase. just signup with email and password and signin with email and password. i dont want to use any frontend stuff. i want to do it with nextjs api routes. i can sign up the user and i get the sesison returned, but i cant persist it in the cookie. how do i achieve this?



this is my code

 javascript
try {
        const { data, error } = await supaClientAnon.auth.signUp({
            email,
            password
        });

        if (error) {
            res.status(422).json({ message: error.message });
            return;
        }

        const sess = await supaClientAnon.auth.setSession(data?.session as Session);

        return res.status(201).json({ message: 'Signed up!', data, sess });


    } catch (error) {
        res.status(500).json({ message: 'Something went wrong' });
        return;
    }
Was this page helpful?