Minimal Svelte single-page app built with Vite and TypeScript, set up so it can be hosted on GitHub Pages under a project site URL (https://<user>.github.io/<repository>/).
Repository: github.com/Jeremias0618/Svelte-Deployment-on-GitHub-Pages
Live site (after you enable GitHub Pages on gh-pages or Actions): jeremias0618.github.io/Svelte-Deployment-on-GitHub-Pages
[!NOTE] The live URL only works after you configure GitHub Pages in the repository settings and publish the built
distfolder (for example via GitHub Actions).
| Area | Technology | Role |
|---|---|---|
| UI | Svelte 5 | Components and reactivity |
| Bundler / dev server | Vite 7 | Fast HMR, optimized production builds |
| Language | TypeScript | Static typing |
| Tooling | svelte-check | Svelte + TS diagnostics |
Dev dependencies also include @sveltejs/vite-plugin-svelte, @tsconfig/svelte, and @types/node. See package.json for exact versions.
git clone https://github.com/Jeremias0618/Svelte-Deployment-on-GitHub-Pages.git
cd Svelte-Deployment-on-GitHub-Pages
npm install
npm run dev
Open the URL Vite prints (usually http://localhost:5173/).
| Command | Description |
|---|---|
npm run dev |
Start the dev server with HMR |
npm run build |
Production build to dist/ |
npm run preview |
Preview the production build locally |
npm run check |
Run svelte-check and TypeScript on Node config |
vite.config.tsGitHub project sites are served from a subpath: /<repository-name>/. Vite must emit asset URLs with that prefix, which is what base does.
[!IMPORTANT] The minimal snippet you often see in docs only shows
basefor brevity. In this project you still needplugins: [svelte()]from@sveltejs/vite-plugin-svelte. The correct shape is both:baseand the Svelte plugin (plus any other options you add later).
If you rename the repository, update the repoName constant in vite.config.ts so base stays correct.
[!TIP] For a user or organization site (
username.github.iowith the repo namedusername.github.io), the site is served from the root; in that case usebase: '/'instead.
npm run build and upload the contents of dist/ to the branch or artifact GitHub Pages uses, ornpm ci, npm run build, and deploys dist with actions/upload-pages-artifact / actions/deploy-pages.Ensure the repository Settings → Pages source matches how you publish.
├── public/ # Static assets copied as-is
├── src/
│ ├── assets/
│ ├── lib/ # Example components (e.g. Counter)
│ ├── App.svelte
│ └── main.ts
├── index.html
├── vite.config.ts
├── svelte.config.js
└── tsconfig*.json
Visual Studio Code with the Svelte extension.