SolidJS SPA with Better Auth
I am trying to build a SolidJS SPA that uses the new Better Auth library to manage all things related to authentication/authorization for my app. Post all the needed configuration for it, on the SPA side, I have to use the Better Auth client to invoke all the auth related methods on my UI. I have one example here that I'm wrestling with in trying to get a redirect to happen after the user signs in but the redirect is not happening on the Solid SPA side:
My Better Auth Client configuration:
My
SignIn
component:
I'm suspecting that perhaps, the issue has to do with the fact that I am doing the throw redirect
inside of the onSuccess
handler of the Better Auth client as opposed to the scope of the action
itself? Wondering if others have attempted this yet.4 Replies
My guess is what you suggested, the
throw
needs to be handled in the action's scopeGotcha -- let me see if Better Auth supports the non-callback expression for the signIn API call.
If it doesn't you can wrap it in your own promise
Yeah, this worked out in the end: