#sign in

2 messages · Page 1 of 1 (latest)

plush yarrowBOT
#

Hi @left yarrow. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

Yes, it is possible to sign in without using the React hook useAuthActions, but the recommended and documented approach for Convex Auth in React is to use useAuthActions, which provides the signIn and signOut methods in a convenient way for React components.

However, if you want to sign in programmatically (for example, outside of React components or hooks), you can directly call the underlying API endpoint or action that handles sign-in. According to a Discord support thread, for password authentication, you can call the sign-in endpoint yourself and get the token and refresh token back. The relevant server-side function is exposed at api.auth.signIn, which you can invoke directly from your client or backend logic, bypassing the React hook layer. This is particularly useful for migration scripts or backend flows, but you should be aware of the security implications and token handling requirements in such cases.

Here’s a relevant quote:

but for password, sure you can just call the endpoints yourself and get the token and the refresh token back. What are you going to do with these though?

... you can call the action that signIn calls directly too

that’s exposed at api.auth.signIn
Discord support thread

So, while useAuthActions is the standard for React apps, you can use api.auth.signIn directly if you need to sign in outside of React hooks. The exact usage will depend on your app’s architecture and where you need to perform the sign-in. If you need a code example or more details, please specify your use case (e.g., Node.js script, backend action, etc.).

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: