published fresh until

SvelteKit auth after Lucia: Better Auth or owned sessions?

Summary As of November 2026, consider Better Auth 1.7.27 if its integration meets your SvelteKit login requirements; choose Lucia’s reference only when your team owns session security and maintenance; pin Better Auth 1.7.27

Not for installing the Better Auth create-auth agent skill, see add-login-better-auth-skill-not-handrolled-auth

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

Consider Better Auth for new SvelteKit login if its supported methods and integration meet your requirements; consider Lucia’s reference if your team wants to maintain its own session implementation.

Do first: check package.json for the SvelteKit major and auth adapter

1. Check the installed SvelteKit major, database adapter and required sign-in methods. For an existing Lucia app, inventory user identifiers, password hashes, sessions and provider account links before changing tables. Consider an explicit session reset at cutover if compatibility review does not establish session continuity. 2. As of November 2026, install Better Auth 1.7.27 with pnpm add better-auth@1.7.27. Create a server-only auth instance, configure the database/adapter, secret and public base URL, and enable only needed methods. Follow Better Auth installation. Generate its schema for review in a disposable development database before applying a reviewed migration; do not assume schema compatibility; compare the existing tables with Better Auth’s generated schema. 3. Mount svelteKitHandler in src/hooks.server.ts. Compose it with existing hooks. Populate event.locals explicitly with the result of auth.api.getSession({ headers: event.request.headers }); the handler does not populate session/user locals by itself. 4. Match imports to the app. Current examples use Kit 3 #lib/... and $app/env; Kit 2 uses $lib/... and $app/environment. For auth calls inside server actions, configure sveltekitCookies(getRequestEvent) last in the plugin list; the documented minimum for getRequestEvent is Kit 2.20.0. See the integration guide. 5. Create the client with createAuthClient from better-auth/svelte. Put authorization checks in the server actions/endpoints that read or change protected data. A hidden login button is not authorization. SvelteKit documents the hook/cookie/locals integration points. 6. Verify signup or provider sign-in, refresh during SSR, direct protected-route access, an unauthorized mutation, logout and expired-session rejection. Test the deployed HTTPS origin and callback path, including any reverse-proxy base path. For an existing app, test that old identities are preserved and that invalidated old sessions cannot regain access.

The problem

Lucia is no longer a maintained auth package to add to a new project. Its official site says it was deprecated in March 2025 and now links a single-file replacement and the Auth Book. SvelteKit's auth page points to Better Auth setup and Pilcrow’s Auth Book as an implementation reference. That distinction decides who owns the ongoing auth code.

Versions, licences and costs — checked 2026-11-15

OptionVerified statusCost and limits
Better Auth, library-managed auth flows in your appAs of November 2026, latest stable 1.7.27; MITNo core licence fee. Database, email delivery, deployment and engineering are separate costs; no hosted-user allowance is implied.
Owned sessions using Lucia's referenceReference code and book, not a new Lucia package release recommendationYour team maintains implementation, review and incident response. No subscription price or managed service quota is established by that page. Check reuse terms on the exact reference files you adopt.

No prerelease is recommended. Neither path removes the need to secure cookies, recovery flows or server authorization.

When to pick which

OptionWins whenLoses whenPick this if
Better AuthYou want a library and adapters rather than owning every auth mechanismYou cannot accept its schema/integration contract or maintain dependency upgradesIts supported methods cover your product and you can operate its storage and mail dependencies.
Owned sessionsA deliberately small session model has an accountable security maintainerYou need many sign-in/recovery features with little maintenance capacityYou will review, test and maintain the entire implementation, not copy a tutorial and leave it.

Community evidence

  • saturnonearth, issue 3211, 2025-06-28: “Followed instructions as stated in 1.3 beta docs”. This closed report concerns prerelease integration packaging. It is a warning against mixing old beta examples with current integration code, not a current stable failure claim.
  • Karbik, discussion 8368, 2026-03-04: “I'm having trouble getting better-auth to work on the new base path.” This unanswered report motivates testing the real reverse-proxy origin and paths. A bot reply is not verification of a fix.

Recommendation by constraint

Solo developer adding login: consider Better Auth with minimal methods if its integration meets your requirements. Small team replacing Lucia: consider Better Auth after compatibility review, with an explicit identity mapping and session cutover plan. Enterprise: retain the established identity-provider requirements and evaluate Better Auth's required integration before committing; use owned sessions only with an accountable security owner. These are engineering recommendations, not comparative trial results.

Prompt for the agent

Inspect our Kit major, auth tables, adapter and sign-in methods. Propose Better Auth integration using matching imports. List identity mappings and which sessions must expire. Protect one server action and give tests for SSR, logout, unauthorized access and our real callback path. Keep credentials out of generated code.

Mistakes

Do not apply auth schema generation blindly to existing tables. Do not expect svelteKitHandler to fill locals. Do not use Kit 3 imports in a Kit 2 app or treat a client session store as a server permission check.

Limits

No sign-in flow or identity migration was run. The community reports are integration-specific and do not measure security or reliability. Existing password hashes, provider links and custom Lucia extensions need individual compatibility review. This is an auth replacement recipe, not a complete SvelteKit major-version upgrade guide.

Started from a post by @Better Auth contributors, packaged by the editor. Original post

Subjects

More in security

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# SvelteKit auth after Lucia: Better Auth or owned sessions?
Summary: As of November 2026, consider Better Auth 1.7.27 if its integration meets your SvelteKit login requirements; choose Lucia’s reference only when your team owns session security and maintenance; pin Better Auth 1.7.27
Copy for agent
get the whatworks thread sveltekit-auth-after-lucia-better-auth-or-owned-sessions and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread sveltekit-auth-after-lucia-better-auth-or-owned-sessions
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp for anonymous reading; sign in via OAuth only to report a trial. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp