@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.

v0.29.34TemplateSvelteKit 2.xSvelte 5.18Vite 7.3TS 5.9

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.ts with SQLite database and optional AI provider
  • .env.example with starter environment variables

Usage

With smrt CLI (recommended)

bash
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:5173

Programmatic Usage

typescript
import { copyTemplate } from '@happyvertical/smrt-template-sveltekit';

copyTemplate('./my-new-project', {
  name: 'my-app',
  overwrite: false,
});

Package Exports

  • getTemplatePath() — returns the absolute path to the template/ directory
  • copyTemplate(destination, options) — copies template files with project-name substitution in package.json
  • templateInfo — 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

VariableRequiredDescription
DATABASE_URLYesDatabase path (default: ./data/app.db)
DATABASE_TYPEYesDatabase engine (default: sqlite)
PUBLIC_SITE_NAMENoDisplay name for the site
PUBLIC_SITE_URLNoPublic URL (default: http://localhost:5173)
OPENAI_API_KEYNoOpenAI API key for AI features
ANTHROPIC_API_KEYNoAnthropic 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.localtenantId='acme'). The resolution strategy is swappable in src/lib/server/tenancy.ts.