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 with openssl rand -base64 32.
  • OAuth redirect URIs changed. Register {ORIGIN}/api/auth/callback/google and {ORIGIN}/api/auth/callback/github. The old /login/google/callback and /login/github/callback routes are gone. /login/google and /login/github still exist as start routes.
  • Minimum password length is now 8 (was 6). Existing shorter passwords keep working until they are changed.
  • Session cookie: auth_session is replaced by better-auth.session_token, HMAC-signed with BETTER_AUTH_SECRET. Everyone signs in again after the upgrade.
  • Schema: users.password_hash and the oauth_accounts and password_reset_tokens tables are removed. Passwords and OAuth links move to accounts, reset tokens to verifications. users gains email_verified, display_username, banned, ban_reason, and ban_expires. sessions gains a token column and uses timestamps for expiry.
  • Removed dependencies and code: arctic, @oslojs/encoding, src/lib/server/oauth.ts, the OAuth callback routes, and the generateSessionToken, createSession, validateSession, invalidateSession, setSessionCookie, and deleteSessionCookie functions, plus the SESSION_COOKIE_NAME constant. Use auth.api.* with request.headers instead, and locals.user / locals.session for the current user.
  • Emails: password-reset and email-change links go through sendAuthEmail() in src/lib/server/email.ts. It logs to the console until you connect an email provider.
  • Tests: mock the database with mockDbModule(), create sessions with createAuthHeaders(), and register src/test-setup.ts in Vitest setupFiles. 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

  1. Back up your database file (the migration also writes its own copy).
  2. Set BETTER_AUTH_SECRET in the server environment (and in your local .env). Keep ORIGIN set to the public URL.
  3. Update OAuth redirect URIs with Google and GitHub to the new /api/auth/callback/* addresses. Skip this if you do not use social login.
  4. Update the code and install: pull v2.0 and run pnpm install.
  5. Run the migration before anything else touches the schema. Point DATABASE_URL at your database if it is not svelteforge.db.
  6. Confirm the schema with pnpm db:push. It should report no changes.
  7. 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_hash to an accounts row with providerId = "credential".
  • Moves Google and GitHub links from oauth_accounts to accounts, and marks those users' emails as verified.
  • Adds the new users columns, sets display_username from username, and drops password_hash.
  • Recreates sessions in the new shape (all existing sessions are dropped) and drops oauth_accounts and password_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 passing request.headers, and convert errors with authFailure().
  • Do not insert users or passwords directly. Use auth.api.signUpEmail() or auth.api.createUser() so the credential account is created too.
  • Anything querying users.passwordHash or oauthAccounts must read accounts instead.
  • 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.cookies to 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.