Is there any downsides to using better Auth WITHOUT the handler and client?
Are there any meaningful downsides/issues that could arise without using the handler and just calling the API Directly other than DX with having to create all the routes ETC?
Will hooks still work same with all the plugins etc?
Example Repo to with sign up/in/out without the handler: https://github.com/lonelyplanetdev/better-auth-without-handler
GitHub
GitHub - lonelyplanetdev/better-auth-without-handler
Contribute to lonelyplanetdev/better-auth-without-handler development by creating an account on GitHub.
25 Replies
I think maybe the downside will be you have to keep manage two api inside your client codes one for your normal api and one for better-auth
Im not adding the handler at all
Check out the repo and have a look there is no /api/auth catch all for better auth
I checked your repo, and I see you used ssr code inside your page.tsx
Im just using the better auth callable api
that is what I mean
Hmm? By removing the better auth api handler for like nextjs or node and just using the the callable functions from better auth saves me from that hassle?
I don't plan on using provided client
either me too
but I think you still have your server side auth code: https://github.com/lonelyplanetdev/better-auth-without-handler/blob/main/src/lib/auth.ts
GitHub
better-auth-without-handler/src/lib/auth.ts at main · lonelyplanetd...
Contribute to lonelyplanetdev/better-auth-without-handler development by creating an account on GitHub.
but I am wondering how can I merge hono app and that auth together!
I haven't mounted the handle i have skipped step 7 and and 8 https://www.better-auth.com/docs/installation#mount-handler
Installation | Better Auth
Learn how to configure Better Auth in your project.
wait! I think you still need step 7, because they create routes for auth, isn't?
otherwise, it won't work
No you dont that is for client thats what i believe
The better-auth.api are basically just functions
thats what im asking in the thread 😅
no..... it is for server
Give the repo a run
It said:
better auth uses #better-call under the hood
which means a better call endpoint is a function and you use a handler to mount that function to the framework api routes
does this repo work?
yes
I think it shouldn't!
Load it up on stackblitz
I won't!
I am pretty surprised that works
because when I forgot to create server side auth, it doesn't work
It returned me: 404 not found 😄
GitHub
GitHub - Bekacru/better-call: a tiny web framework for typescript
a tiny web framework for typescript. Contribute to Bekacru/better-call development by creating an account on GitHub.
I think, it worked because there is no other routes inside your codebase, maybe!
Its working because better auth is just better-call but with authentication routes and logic,
"Better call is a tiny web framework for creating endpoints that can be invoked as a normal function or mounted to a router to be served by any web standard compatible server (like Bun, node, nextjs, sveltekit...) and also includes a typed RPC client for typesafe client-side invocation of these endpoints."
Specifically: invoked as a normal function OR mounted to a router to be served by any web standard compatible server
The main drawback is you don't get the better-auth client, which has some addtional logic for thing like passkeys which use @simplewebauthn/browser
sorry man! good talk, but I have to still work on my product