SvelteKit via sv create
This variant hands the SvelteKit scaffold to the official sv CLI (npx sv@latest create), then layers Phoenix wiring on top. Pick this when you want to use the canonical Svelte adders — Tailwind, Drizzle, Lucia, Prettier, ESLint, Storybook — and have Tostada handle just the Phoenix backend integration.
Install
npx tostada-cli create MyApp --variant sveltekit-sv Or interactively pick SvelteKit (via npx sv create) at the variant prompt.
What happens
- CLI downloads the Tostada shared base (
server/,Makefile,scripts/) - CLI runs
npx sv@latest create client --no-install— you interact with sv directly to pick a template (default, demo, library) and adders (Tailwind, Lucia, Drizzle, etc.) - CLI applies a small Phoenix-wiring overlay into
client/:vite.config.ts— Phoenix proxy for/api,/socket,/users,/live,/assetssvelte.config.js—adapter-staticoutputting to../server/priv/static/app, base path/appin productionsrc/lib/socket.ts— Phoenix socket helpersrc/phoenix.d.ts— TypeScript types for thephoenixnpm package
- CLI adds two deps to
client/package.json:@sveltejs/adapter-static,phoenix - CLI runs
mix deps.get+npm install(unless--no-install)
What’s overlaid (what tostada owns)
The overlay only replaces files that need Phoenix-specific configuration. Everything else from sv create is yours: routes, components, styling, your picked adders.
| File | Why tostada owns it |
|---|---|
vite.config.ts | Needs the proxy block so dev mode reaches Phoenix |
svelte.config.js | Needs adapter-static + base path /app |
src/lib/socket.ts | Phoenix client helper |
src/phoenix.d.ts | Types for phoenix |
If you used sv create’s Tailwind adder, your overlay-injected files don’t disturb it — Tailwind config, app.css, and any added routes are untouched.
Picking sv adders
When sv create prompts, you can pick any combination — Tostada doesn’t care which adders you choose. Some pairings worth noting:
- Tailwind — fine, no conflict with the Phoenix backend’s tailwind (Phoenix’s tailwind only styles server-rendered LiveView pages, which Tostada doesn’t use by default)
- Drizzle — works against the same Postgres database Phoenix uses; you’d point Drizzle at the same
DATABASE_URLPhoenix configures - Lucia — overlaps with Phoenix’s session auth. If you want client-side auth, disable Phoenix’s
:require_authenticated_userplug for the/appscope - Prettier / ESLint — no conflict
Available addons
| Addon | Default | Notes |
|---|---|---|
docker | off | Dockerfile + docker-compose for containerized deploy |
Verifying the install
cd MyApp
make db.setup
make dev If sv create didn’t generate a landing page (e.g., you picked the minimal template), add src/routes/+page.svelte yourself.
Caveats
sv createis interactive — you can’t fully script this variant without piping inputsnpm installonly runs once Phoenix wiring is layered in, so@sveltejs/adapter-staticandphoenixresolve correctly on first install- If
sv createpicks a different SvelteKit adapter (e.g.adapter-auto), the overlay overwrites that choice withadapter-staticso the Phoenix/appmount works