Logo VelaStack

Enable Backend

Add the PocketBase backend to a SvelteKit project that has none — one scaffolded from the static template, or one the backend was removed from. Installs @velastack/pocketbase, pocketbase-sveltekit and @sveltejs/adapter-node, composes handlePocketbase into src/hooks.server.ts alongside the handles already there, scaffolds the data directory the database runs from with fixtures, hooks and seeds inside, and writes the test/setup.ts that gives server tests their PocketBase clients. Run through the CLI it also asks for an admin email and password, creates that superuser and records it in .env, so the database is usable the moment vela dev starts it. Everything else that needs a database — auth, the API, scaffolds, seeds and fixtures — builds on this.

$ vela enable backend
data/fixtures/README.md
Sample data for development
data/hooks/README.md
# Hooks

Add \*.pb.js hooks here to extend PocketBase: https://pocketbase.io/docs/js-overview/
data/seeds/README.md
Essential system-level data (e.g., roles, locales)
src/hooks.server.ts
import { env } from "$env/dynamic/private";
import { handlePocketbase } from "@velastack/pocketbase";

export const handle = handlePocketbase({
  pocketbaseUrl: env.POCKETBASE_URL,
  superuserEmail: env.POCKETBASE_SUPERUSER_EMAIL,
  superuserPassword: env.POCKETBASE_SUPERUSER_PASSWORD,
});