Upgrading
Newest release first. Upgrade one major version at a time and back up your SQLite database before each step.
Upgrading to v2.0
v2.0 replaces the hand-rolled authentication (Arctic OAuth and SHA-256 session tokens) with Better Auth 1.7.15. The user experience is the same, but the database schema, environment, OAuth redirect URIs, and server-side auth APIs changed. Existing passwords and OAuth links are preserved by a migration script; every user is signed out once because sessions cannot be carried over.
Breaking changes
- New required variable:
BETTER_AUTH_SECRET. The app refuses to start in production without it. Generate it withopenssl rand -base64 32. - OAuth redirect URIs changed. Register
{ORIGIN}/api/auth/callback/googleand{ORIGIN}/api/auth/callback/github. The old/login/google/callbackand/login/github/callbackroutes are gone./login/googleand/login/githubstill exist as start routes. - Minimum password length is now 8 (was 6). Existing shorter passwords keep working until they are changed.
- Session cookie:
auth_sessionis replaced bybetter-auth.session_token, HMAC-signed withBETTER_AUTH_SECRET. Everyone signs in again after the upgrade. - Schema:
users.password_hashand theoauth_accountsandpassword_reset_tokenstables are removed. Passwords and OAuth links move toaccounts, reset tokens toverifications.usersgainsemail_verified,display_username,banned,ban_reason, andban_expires.sessionsgains atokencolumn and uses timestamps for expiry. - Removed dependencies and code:
arctic,@oslojs/encoding,src/lib/server/oauth.ts, the OAuth callback routes, and thegenerateSessionToken,createSession,validateSession,invalidateSession,setSessionCookie, anddeleteSessionCookiefunctions, plus theSESSION_COOKIE_NAMEconstant. Useauth.api.*withrequest.headersinstead, andlocals.user/locals.sessionfor the current user. - Emails: password-reset and email-change links go through
sendAuthEmail()insrc/lib/server/email.ts. It logs to the console until you connect an email provider. - Tests: mock the database with
mockDbModule(), create sessions withcreateAuthHeaders(), and registersrc/test-setup.tsin VitestsetupFiles. See Testing.
What stays the same
- Argon2id with the same parameters, so existing hashes verify without a password reset.
- Login by username, three roles (admin, editor, viewer), and 30-day sliding sessions.
- The first registered account becomes admin; all later accounts are viewers.
- Content, notifications, and app settings are untouched.
Upgrade steps
- Back up your database file (the migration also writes its own copy).
- Set
BETTER_AUTH_SECRETin the server environment (and in your local.env). KeepORIGINset to the public URL. - Update OAuth redirect URIs with Google and GitHub to the new
/api/auth/callback/*addresses. Skip this if you do not use social login. - Update the code and install: pull v2.0 and run
pnpm install. - Run the migration before anything else touches the schema. Point
DATABASE_URLat your database if it is notsvelteforge.db. - Confirm the schema with
pnpm db:push. It should report no changes. - Restart the app and sign in again.
cp svelteforge.db svelteforge.db.manual-backup
openssl rand -base64 32 # put the output in BETTER_AUTH_SECRET
pnpm install
pnpm db:migrate-v2 # writes svelteforge.db.pre-v2.bak, then migrates
pnpm db:push # expect "No changes detected" Run db:migrate-v2 before db:push. Pushing the new
schema first would drop users.password_hash without copying it, losing every password.
What the migration does
- Copies each user's Argon2id hash from
users.password_hashto anaccountsrow withproviderId = "credential". - Moves Google and GitHub links from
oauth_accountstoaccounts, and marks those users' emails as verified. - Adds the new
userscolumns, setsdisplay_usernamefromusername, and dropspassword_hash. - Recreates
sessionsin the new shape (all existing sessions are dropped) and dropsoauth_accountsandpassword_reset_tokens, so pending reset links stop working. - Runs inside a transaction and finishes with a foreign-key check. It refuses to run on a database that has already been migrated.
Customized code
- Replace calls to the removed session helpers with
auth.api.*methods, always passingrequest.headers, and convert errors withauthFailure(). - Do not insert users or passwords directly. Use
auth.api.signUpEmail()orauth.api.createUser()so the credential account is created too. - Anything querying
users.passwordHashoroauthAccountsmust readaccountsinstead. - Role changes, deletions, and (in demo mode) edits to the shared demo account are guarded inside
Better Auth, so they also apply to direct
/api/auth/*requests.
See Authentication for the full configuration. Two-factor authentication, passkeys, organizations, and impersonation are not part of the free edition.
Upgrading to v1.4
v1.4 adopts SvelteKit 3, Svelte 5, Node adapter 6, and pnpm 12. Back up your SQLite database and review local customizations before updating. The release does not require a schema migration.
Runtime and packages
Use Node 22.17 or newer (Node 24 is used in CI and Docker), and the pnpm version pinned in package.json. TypeScript stays on 6 because the current Svelte tooling does not support 7. The lockfile
records both application dependencies and pnpm’s integrity metadata; commit both YAML documents.
pnpm install --frozen-lockfile
pnpm check
pnpm lint
pnpm format:check
pnpm test
pnpm test:e2e Configuration and imports
SvelteKit options now live in sveltekit(...) in vite.config.ts. Remove
the old svelte.config.js. The #lib imports are declared in package.json; include extensions and use index.js for directory exports.
import { Button } from "#lib/components/ui/button/index.js";
import { db } from "#lib/server/db/index.js";
import { dev } from "$app/env";
import { GOOGLE_CLIENT_ID } from "$app/env/private"; The TypeScript config extends $app/tsconfig. Optional OAuth variables are declared in src/env.ts; an empty value disables its provider.
Production origin
Set ORIGIN before building. The Vite configuration passes it to paths.origin, which replaces adapter-node’s runtime origin setting. Rebuild if the
public URL changes. Keep ORIGIN in the runtime environment too because OAuth uses it for
callback URLs.
ORIGIN=https://admin.example.com pnpm build
node --env-file=.env build/index.js
# Docker: bake the public origin into the build
docker build --build-arg ORIGIN=https://admin.example.com -t svelteforge-admin . Permissions and integration changes
- Only the first registered account receives admin access; later accounts are viewers.
- Role changes require admin access. Editors can create/edit content and delete their own content. Viewers cannot mutate content.
- Pass
event.cookiesto session-cookie helpers, and await async session functions. - External OAuth redirects explicitly opt in to the provider’s origin. Use
Response.json()for JSON endpoints.
Verify deployment
The GitHub deployment workflow installs matching server dependencies and verifies the build commit
through /api/health. Confirm login, protected routes, docs, and charts after
deployment. Never run the demo seed against a production database containing customer data.
For customized applications, also consult the official SvelteKit 3 migration guide.