This template will help get you started developing with SvelteKit in Site.js.
It’s based on the create-svelte
template.
Note: if you want to use vanilla Vite + Svelte instead of SvelteKit, check out the site-vite-svelte template instead. This template also has the advantage, currently, of running the dev server on https://localhost:444 instead of http://localhost:3000. We can’t do that with SvelteKit’s dev server (yet?) as it doesn’t currently run correctly with HMR over https and there isn’t a way to set the server
property directly on its Vite instance.
By using Site.js you can extend your static SvelteKit clients using dynamic DotJS routes, WebSockets, a JavaScript database, etc., and easily deploy to your own server using the built-in sync feature.
Download the template:
npm init using small-tech/sitekit my-project
This will download this template using create-using into a directory called my-project
.
Use the template on GitHub:
Click the green “Use this template” button on the GitHub page to create your own repository using this template.
Do it old-skool:
Just fork this repository and clone it as you normally do using git
.
cd my-project
npm i
npm run dev
This will run the dev.sh
script that:
npx svelte-kit build
Once the servers are running, you will have:
http://localhost:3000
with HMR.https://localhost
with all features (including serving dynamic DotJS routes and WebSockets, etc.)Note that the SvelteKit build is not automatically updated when hitting the Site.js endpoint. To update it, run the build command (see below).
Also note that the dev.sh
script will only run on Linux-esque systems. If you’re on Windows, please run the commands listed above manually. Pull requests are welcome for a dev-windows
task that runs a PowerShell script to do the same thing.
npm run kit
This will run the SvelteKit dev server only (not Site.js) at http://localhost:3000
.
npm run build
This will build the SvelteKit source into the .generated
folder that is served by Site.js.
npm run serve
This will:
vite build
Hit https://localhost
to view and test your site.
Note that the Vite dev server will not be run. If that’s what you want, please run the dev task.