@happyvertical/template-sveltekit
Base SvelteKit project template used by smrt gnode create. Scaffolds a full-stack app with the SMRT Vite plugin, auto-generated REST routes, TypeScript, and SQLite.
Overview
@happyvertical/smrt-template-sveltekit is the base SvelteKit project template
that smrt gnode create <name> --template sveltekit scaffolds. The generated
project ships with the SMRT Vite plugin for automatic REST route generation, an example @smrt() object, server-side SMRT initialisation, SQLite, and an .env.example to edit before first run.
Pinned tooling stack: Vite ^7.3.1, TypeScript ^5.9.3, Svelte ^5.18.0, and @sveltejs/kit ^2.46.0. The package declares @happyvertical/smrt-core ^0.29.1 as a peer dependency; the generated project pins
the SMRT runtime packages it depends on (smrt-core, smrt-tenancy, smrt-users).
What the Template Provides
- SvelteKit 2.x with Svelte ^5.18 and TypeScript ^5.9
smrtPlugin()Vite ^7.3 integration for automatic REST API route generation- Example
@smrt()object (template/src/lib/objects/Item.ts) with barrel export - Server-side SMRT initialisation (
template/src/lib/server/) smrt.config.tswith SQLite database and optional AI provider.env.examplewith starter environment variables
Usage
With smrt CLI (recommended)
smrt gnode create my-app --template sveltekit
cd my-app
pnpm install
cp .env.example .env # Edit with your values
pnpm dev # Dev server at http://localhost:5173Programmatic Usage
import { copyTemplate } from '@happyvertical/smrt-template-sveltekit';
copyTemplate('./my-new-project', {
name: 'my-app',
overwrite: false,
});Package Exports
getTemplatePath()— returns the absolute path to thetemplate/directorycopyTemplate(destination, options)— copies template files with project-name substitution inpackage.jsontemplateInfo— metadata object (SvelteKit 2.x, Svelte 5, REST API, SMRT CLI, SQLite)
Project Name Substitution
When copyTemplate() runs with a name option, it copies the template
files verbatim and then rewrites the name field of the generated package.json. The template files themselves contain no token placeholders — the
only substitution is the generated project's package name.
Environment Variables
| Variable | Required | Description |
|---|---|---|
DATABASE_URL | Yes | Database path (default: ./data/app.db) |
DATABASE_TYPE | Yes | Database engine (default: sqlite) |
PUBLIC_SITE_NAME | No | Display name for the site |
PUBLIC_SITE_URL | No | Public URL (default: http://localhost:5173) |
OPENAI_API_KEY | No | OpenAI API key for AI features |
ANTHROPIC_API_KEY | No | Anthropic API key (alternative AI provider) |
Multi-Tenancy (pre-wired)
The generated project wires multi-tenancy out of the box: src/hooks.server.ts registers the tenancy interceptor, loads sessions, and
resolves the tenant from a leading subdomain (e.g. acme.demo.local → tenantId='acme'). The resolution strategy is swappable in src/lib/server/tenancy.ts.