You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I find getting better auth setup and going through the sveltekit guide and creating a small demo takes the longest, I think better auth has reached a good stable point and it's double the size of lucia auth by now and growing making it a save bet to add
Reacted by Azzam Albugami, Yuki Kobayashi, Gabriel, Naol Fekadu, Olle Månsson, tom, Scott Wu, Ross, enchart, pakhrom and 1 more
I also did the switch from lucia-style to better-auth and I have to say that I'm pretty happy about it!
But I don't know if sv want to have all options possible. For example there is drizzle and not prisma, there is prettier and not biome, ... Maybe community addon could answer this ?! I don't know :)
Yeah, I think we'd probably want a community add-on for it.
I've been a bit annoyed at how many dependencies better-auth has. E.g. they include kysley as a dependency and we offer drizzle so you'd end up with two orms in your dependency tree.
I've been hoping to improve our auth add-on a bit. I sent a PR to grant for SvelteKit support, which would let us support over 200 services via OAuth. I'm waiting for a review there, however.
I do agree that our auth setup could use a rework with a different library under the hood. Leaving this open for visibility at the moment and to gather more opinions. Apart from that, I think everything has been said.
Side note:
Coming from the c# world, as soon as you add auth to a template, you are greeted with way more than what we currently provide. I'm not necessarily saying that we should provide all of this, but we could take some ideas:
Chatting with the other maintainers about this and there's no clear consensus on whether we should make better-auth the officially recommended auth solution for Svelte. The main complaint that a couple of people have is that it requires client-side JS. I just filed an issue to see whether that's something that might be able to be addressed: better-auth/better-auth#6204
I mean, if you use client-side authentication methods like passkeys, then it doesn't really matter which library you use or no library at all. Then sure, JS would be required in those cases.
@sillvva they do have a server side counterpart...very often however is not documented at all AND it's a bit annoying to use...for example the example you posted about social login will not work (at least for GitHub) because they need to set the cookie for the state parameter.
They also do some silly thing, like you could technically do asResponse to get back an actual response but that doesn't include a Location header so you still need to manually redirect (and you would still need to manually set cookies).
I'm going to ask around the team on our side to understand why we don't just use the set-cookie header as it seems like a poor user experience. It'd be much easier if you didn't need the sveltekitCookies plugin. That part is on us and I can't say I know why it's required today, so I'll at least try to get an answer to that and see if it's something that we can change
That was referenced here. It doesn't actually matter since kysely will be downloaded either way and if you're not using it , rollup should treeshake it away.
Activity
[-]Adding better auth as an option[/-][+]better-auth addon[/+]jycouet commentedon Aug 2, 2025
I also did the switch from
lucia-styletobetter-authand I have to say that I'm pretty happy about it!But I don't know if
svwant to have all options possible. For example there is drizzle and not prisma, there is prettier and not biome, ... Maybe community addon could answer this ?! I don't know :)jycouet commentedon Aug 2, 2025
Side comment / Self promo
If you want to spin up a
better-authdemo, you can do:npm init remult@latest.Then you ca use
svto add stuff in it ;)benmccann commentedon Aug 2, 2025
Yeah, I think we'd probably want a community add-on for it.
I've been a bit annoyed at how many dependencies better-auth has. E.g. they include kysley as a dependency and we offer drizzle so you'd end up with two orms in your dependency tree.
I've been hoping to improve our auth add-on a bit. I sent a PR to
grantfor SvelteKit support, which would let us support over 200 services via OAuth. I'm waiting for a review there, however.manuel3108 commentedon Aug 2, 2025
I do agree that our auth setup could use a rework with a different library under the hood. Leaving this open for visibility at the moment and to gather more opinions. Apart from that, I think everything has been said.
Side note:
Coming from the c# world, as soon as you add auth to a template, you are greeted with way more than what we currently provide. I'm not necessarily saying that we should provide all of this, but we could take some ideas:
sacrosanctic commentedon Nov 22, 2025
@benmccann I'd like to request a reconsideration on
better-auth. They have removed@simplewebauthnandkyselyis now optional.https://npmgraph.js.org/?q=better-auth@1.3.34
https://npmgraph.js.org/?q=better-auth@1.4.0
benmccann commentedon Nov 22, 2025
Much better! kysely is still in the dependency graph unfortunately. I just filed an issue for that one
sacrosanctic commentedon Nov 22, 2025
tracking better-auth/better-auth#6183
sacrosanctic commentedon Nov 22, 2025
Are there other blockers? If we can add it as an official addon, I'd be happy to contribute.
benmccann commentedon Nov 22, 2025
Chatting with the other maintainers about this and there's no clear consensus on whether we should make better-auth the officially recommended auth solution for Svelte. The main complaint that a couple of people have is that it requires client-side JS. I just filed an issue to see whether that's something that might be able to be addressed: better-auth/better-auth#6204
sillvva commentedon Nov 22, 2025
As far as I know, all of the client-side functions can be performed with the the server-side API via load/action/remote functions.
https://www.better-auth.com/docs/concepts/api
sacrosanctic commentedon Nov 22, 2025
As @sillvva mentioned, every backend call has a corresponding endpoint. But some API's still require JavaScript, like passkeys.
I understand if the official addon is not an option. I am content with a community addon.
sillvva commentedon Nov 22, 2025
I mean, if you use client-side authentication methods like passkeys, then it doesn't really matter which library you use or no library at all. Then sure, JS would be required in those cases.
paoloricciuti commentedon Nov 22, 2025
@sillvva they do have a server side counterpart...very often however is not documented at all AND it's a bit annoying to use...for example the example you posted about social login will not work (at least for GitHub) because they need to set the cookie for the
stateparameter.They also do some silly thing, like you could technically do
asResponseto get back an actual response but that doesn't include aLocationheader so you still need to manually redirect (and you would still need to manually set cookies).Here's what worked for me:
Bekacru commentedon Nov 22, 2025
Hey all, happy to help get this over the line. We’ve been talking about dropping Kysely as the default, and we’ll sync with the team on it
We’ll support form data
@paoloricciuti you can use the
sveltekitCookiesplugin, it does exactly what you're doing here. It callscookies.setwith theSet-Cookieheader https://www.better-auth.com/docs/integrations/svelte-kit#server-action-cookiesbenmccann commentedon Nov 22, 2025
Thanks! This is very helpful
I filed better-auth/better-auth#6219 with a suggestion to make the redirect portion easier
I'm going to ask around the team on our side to understand why we don't just use the
set-cookieheader as it seems like a poor user experience. It'd be much easier if you didn't need thesveltekitCookiesplugin. That part is on us and I can't say I know why it's required today, so I'll at least try to get an answer to that and see if it's something that we can changebenmccann commentedon Nov 23, 2025
I found sveltejs/kit#8409 regarding the cookies issue. I'll ask around for a bit more clarification though as I'm not understanding it yet
sacrosanctic commentedon Feb 6, 2026
better-auth is now added to the cli via #898 so this issue is now mainly about improving the experience?
jycouet commentedon Feb 6, 2026
oOups, it's was not linked with the issue to auto close it!
Thanks @benmccann
azezsan commentedon Feb 11, 2026
@jycouet I was reading the better auth docs and I would like you to check this section this sounds perfect for our case or am I miss understanding it
sacrosanctic commentedon Feb 11, 2026
#658 (comment)
That was referenced here. It doesn't actually matter since kysely will be downloaded either way and if you're not using it , rollup should treeshake it away.
benmccann commentedon Feb 11, 2026
I'd support switching. Faster install time, less disk usage, and reduced risk of supply chain attacks