SvelteKit Starter

A SvelteKit 3 starter in TypeScript with Svelte 5, rendering on the server through adapter-node, for developers who want a SvelteKit app that runs in any container. It includes a server load function, an About page, a GET /api/health endpoint, ESLint, svelte-check and Vitest.

by Light CloudFull-stack

Build a server-rendered web app with SvelteKit and TypeScript

SvelteKit Starter: home page with a welcome heading and the time from the server load function
SvelteKit Starter: home page with a welcome heading and the time from the server load function, on a phone

Features

  • adapter-node instead of adapter-auto, so npm run build outputs a plain Node.js server in build/
  • Home page with a server load in +page.server.ts that passes the render time, plus an About page
  • A +server.ts endpoint at GET /api/health that answers { status: ok }, with a Vitest test
  • Svelte 5 in runes mode on Vite 8, with a shared SiteHeader component imported through #lib
  • PUBLIC_SITE_NAME declared in src/env.ts and read at runtime through $app/env/public, so changing it needs no rebuild
  • Type checking with svelte-check, and ESLint 9 with typescript-eslint and eslint-plugin-svelte
  • .npmrc sets engine-strict=true, so npm install stops on an unsupported Node.js version
  • The server reads PORT (default 3000) and HOST (default 0.0.0.0)

Tech stack

What you need

  • Free plan: it runs as a server app, and the Free plan includes 3 server apps
  • To run it locally: Node.js 22.17 or later and npm
  • No API keys: it starts with nothing to configure

About

For each request to /, the server runs the load function, renders the page with its data and sends HTML that Svelte then hydrates in the browser. The starter uses adapter-node because adapter-auto only recognises a fixed list of hosts, while a Node.js server runs anywhere. Most people first add routes in src/routes/ with their own +page.server.ts loads, and keep secrets in $app/env/private. SvelteKit and Vitest share one vite.config.ts, and deploying runs npm run build, then npm start (node build) in a container that listens on PORT.

FAQ

Why use adapter-node instead of adapter-auto in SvelteKit?

adapter-auto only recognises a fixed list of hosting platforms. adapter-node builds a standard Node.js server that runs in any container.

How do I add a page with server data in SvelteKit?

Create a folder in src/routes/ with a +page.svelte in it, such as src/routes/contact/+page.svelte for /contact, and add a +page.server.ts next to it for data loaded on the server.

How do I add an API endpoint in SvelteKit?

Create a +server.ts file and export a function per HTTP method, as in src/routes/api/health/+server.ts. src/routes/api/hello/+server.ts with export const GET answers GET /api/hello.

How do I use environment variables in SvelteKit?

Declare each variable in src/env.ts with defineEnvVars, then import it from $app/env/private in server code, or from $app/env/public when it is marked public: true. Variables are read when the server starts, not at build time, unless you mark them static: true.

Can I host this SvelteKit template without Light Cloud?

Yes. Any host with Node.js 22.17 or later runs it with npm run build and node build, or you can swap adapter-node for another platform's adapter in vite.config.ts.

Price
Free
Framework
SvelteKit · JavaScript
Plan
Free
Updated