Svelte site for blog.jonasjones.dev
Find a file
J-onasJones 33d534ca23 cleaned up post loading process
cleaned up code
made 404 and loading sequence prettier
2024-06-15 14:48:01 +02:00
public part of skeleton 2024-06-07 00:26:22 +02:00
src cleaned up post loading process 2024-06-15 14:48:01 +02:00
.gitattributes Initial commit 2024-06-06 22:04:54 +02:00
.gitignore part of skeleton 2024-06-07 00:26:22 +02:00
index.html updated favicon 2024-06-07 16:31:03 +02:00
package-lock.json added post backend 2024-06-09 13:35:02 +02:00
package.json added post backend 2024-06-09 13:35:02 +02:00
README.md part of skeleton 2024-06-07 00:26:22 +02:00
svelte.config.js please be fixed 2024-06-07 01:10:10 +02:00
tsconfig.json part of skeleton 2024-06-07 00:26:22 +02:00
tsconfig.node.json part of skeleton 2024-06-07 00:26:22 +02:00
vite.config.ts part of skeleton 2024-06-07 00:26:22 +02:00

Svelte 3 Up and Running

Want to learn Svelte 3 and how to build a Single-Page App (SPA) with it (and with this router)? Check out my book Svelte 3 Up and Running on Amazon.

Svelte app with svelte-spa-router

This is a project template for Svelte 4 apps that includes svelte-spa-router for client-side routing, TypeScript, and Vite as bundler.

About svelte-spa-router

svelte-spa-router is a client-side router for Svelte 4 apps that leverages hash-based routing (i.e. stores the current view in the URL after the # symbol).

You can read more about the router, and the reasons why you might want to use hash-based routing (or not), in the documentation.

Get started

Install the dependencies…

cd svelte-app
npm install

…then start a dev server using Vite:

npm run dev

Navigate to http://localhost:5050. You should see your app running. Edit a component file in src, save it, and reload the page to see your changes.

You can add more routes by defining them in the src/routes.ts file. More information can be found on the documentation for svelte-spa-router.

By default, the server will only respond to requests from localhost. To allow connections from other computers, edit the vite commands in package.json to include the option --host 0.0.0.0.

If you're using Visual Studio Code we recommend installing the official extension Svelte for VS Code. If you are using other editors you may need to install a plugin in order to get syntax highlighting and intellisense.

Building and running in production mode

To create an optimized version of the app:

npm run build

You can run the newly-built app with npm run preview.