# Svelte

A Svelte 5 single-page app starter in JavaScript on Vite 8, for developers who want one compiled page without a router or server. It includes components using runes, a light and dark theme, ESLint and Vitest with Testing Library.

- Framework: Svelte (JavaScript)
- Category: Starters / Single-page apps
- Creates: a static site
- Plan: Free
- Price: Free
- Author: Light Cloud
- Page: https://templates.light-cloud.com/starters/single-page-apps/svelte-vite-starter
- Updated: 2026-11-21

## Features

- Svelte 5 runes: Counter.svelte uses $state, Layout.svelte uses $props with {@render children()}
- The new onclick event syntax instead of on:click
- A home page made of Hero, Counter and NextSteps components in src/lib/components, each with scoped styles
- Design tokens in src/styles/global.css, with a dark theme through prefers-color-scheme
- Vitest, Testing Library and user-event, with a sample test for the counter
- ESLint flat config with eslint-plugin-svelte
- VITE_APP_TITLE sets the home page heading at build time, documented in .env.example
- No client-side routing, so any static host serves dist/ with no rewrite rules

## What you need

- Free plan: it builds to a static site, which the Free plan hosts with no limit on sites
- To run it locally: Node.js 22.12 or later and npm
- No API keys: it starts with nothing to configure

## About

The Svelte compiler turns each component into plain JavaScript at build time, so the browser downloads only a small runtime and there is no virtual DOM. The page is composed in App.svelte from small components, which makes it easy to replace the hero and links with your own content. Change the heading through VITE_APP_TITLE first, then edit Hero.svelte. When you need several pages or server code, move to SvelteKit. Deploying runs npm run build and serves dist/ from a CDN.

## Questions

### What is the difference between Svelte with Vite and SvelteKit?

This template is plain Svelte on Vite: one page, built to static files, with no router and no server. SvelteKit adds file-based routing, server rendering and endpoints.

### Does this template use Svelte 5 runes?

Yes. Counter.svelte keeps its count in $state and Layout.svelte takes its content through $props and {@render children()}.

### How do I add a second page to a Svelte Vite app?

For several pages, SvelteKit is the simpler path. To stay on this template, add a client-side router package and render a component per path in App.svelte; hosts other than Light Cloud then need a fallback to index.html.

### Is there a free Svelte starter template I can deploy?

Yes. It is MIT licensed, and it builds to a static site, which the Light Cloud Free plan hosts with no card needed.

### Can I host this Svelte template without Light Cloud?

Yes. Run npm run build and serve dist/ from any static host. There is no client-side routing, so no rewrite rules are needed.
